From within a running Android app, I'd like to request that this same app (1) re-download itself from my private web server, (2) reinstall itself, and then (3) restart itself after the reinstallation.
I know how to perform steps 1 and 2, but I haven't figured out how to perform step 3.
After the download, I do step 2 like this (where this.apkpath has previously been set to the full pathname of the downloaded APK on my sdcard):
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(this.apkpath)),
"application/vnd.android.package-archive");
this.activity.startActivity(intent);
}
catch (Throwable t) {
// handle exceptions
}
After this code succeeds, an installation confirmation dialog pops up on my screen, and the reinstallation takes place upon this confirmation. However, after installation, control returns to my desktop manager, and I have to manually restart my newly reinstalled app.
What can I do programmatically to force the app to be automatically restarted after this reinistallation?