0

I have an app 'A' of version 1 already installed in a Android device. And another app 'B' which has version 2 APK of app 'A'. The app 'B' should autamatically update the app 'A' with version 2. I have done it this way:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + apkPath), APK_MIMETYPE);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent); 

The problem is that it prompts for user intervention (asks to click on 'install' button) to update the app 'A'.I require the app 'A' to be updated silently in the background.

Conditions:

  1. The device is not rooted.
  2. System certificate keys are available. The app 'B' can be made to run as a system app with shareduserid as android.uid.system.

Is it possible to do silent upgradation with the above conditions ? Can it be done from shell command programatically using Runtime.getRuntime().exec() API ?

Sam DeHaan
  • 10,246
  • 2
  • 40
  • 48
  • 3
    Not possible. There would be user interaction involved. http://stackoverflow.com/questions/5653151/automatically-install-uninstall-an-application-from-within-another-application – Kumar Bibek Apr 03 '12 at 04:48
  • its' not possible. see also discussion on the link: http://stackoverflow.com/questions/8077779/android-apks-silent-installation – Tal Kanel Apr 03 '12 at 04:51

1 Answers1

0

i don't think it can be achieved without user interaction.you can achieve it by simply a shell script which can install the application via package manager exmple script save it as and make sure to done chmod +x sample.sh via command line or shell

sample.sh

 #!system/bin/sh

 pm install -r Myandroid_application_path/my.apk

Runtime.getRuntime().exec() may be it works for you but its not working for me in my galaxy note i hv tried this code u can try also and if it work pls update

            Process proc = null;

    try {
        Runtime rt = Runtime.getRuntime();
        Process proc= rt.exec("/system/bin/pm install -r /mnt/sdcard/chess.apk");

    } catch (IOException e) {
        // TODO Auto-generated catch block
        Log.d("in catch", ""+proc.getErrorStream());

    }

i hv read some some script runner in android as Gscript but i think its only owrk on rooted phone it is also not able to run in my galaxy note

Vivek Bajpai
  • 1,617
  • 1
  • 19
  • 35