My code installs apk from downloads folder using pm install
(root). The issue is, after the app gets installed, I need to launch the installed app automatically. How do I do that?
File sdCard = Environment.getExternalStorageDirectory();
String fileStr = sdCard.getAbsolutePath() + "/download";// +
// "app-release.apk";
File file = new File(fileStr, "xadb-build.apk");
if (file.exists()) {
try {
String command;
command = "pm install -r " + file;
Process proc = Runtime.getRuntime().exec(
new String[] { "su", "-c", command });
proc.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
}
You can register a broadcast receiver for Action PACKAGE_INSTALLED, on in that receiver you could write the logic for launching that Application's Launch Activity