Install Android APK without prompt -
we writing android app shows ads on big screens. have backend advertisers can select ads, updated instantly. because there lot of android boxes running (plugged hdmi screens), should able update our software remotely.
this case:
main app running continuously (unless turned off) , users never see android related. need updater app listens updates , deletes main apk, installs new apk. while updating show activity "updating, please wait", until new main apk installed , showing.
what need:
we need help on how implement update mechanism without prompting user on rooted device.
what have:
the updater app hooked boot received event, service starts (this service hear updates, implemented colleague soon). service can start activity prompt update info while updating.
in updater activity
seek { process proc = runtime.getruntime().exec(new string[]{"su", "pm install -r /mnt/sdcard/myfolder/testapk.apk"}); stringbuilder.append(string.valueof(proc.waitfor())); stringbuilder.append("\n"); } grab (exception e) { if (e instanceof ioexception) { log.d(tag, "ioexception"); } else if (e instanceof interruptedexception) { log.d(tag, "interruptedexception"); } else { e.printstacktrace(); } }
the stringbuilder prints 11, same if give random unexisting command..
in manifest
<!-- permission start updaterservice on boot --> <uses-permission android:name="android.permission.receive_boot_completed" /> <!-- install/delete permissions, granted scheme apps --> <uses-permission android:name="android.permission.install_packages" /> <uses-permission android:name="android.permission.delete_packages" /> <uses-permission android:name="android.permission.write_external_storage" />
the install packages , delete packages useless if don't install app scheme app, correct?
long story short, no installation of test apk, , have no thought how solve this. help appreciated!
you can utilize adb install command install/update apk silently. sample code below
public static void installapk(string filename){ file file = new file(filename); if(file.exists()){ seek { string command; command = "adb install -r " + filename; process proc = runtime.getruntime().exec(new string[] { "su", "-c", command }); proc.waitfor(); } grab (exception e) { e.printstacktrace(); } } }
or
please check http://paulononaka.wordpress.com/2011/07/02/how-to-install-a-application-in-background-on-android/
android install root
No comments:
Post a Comment