我在StackOverFlow和其他网站上尝试了很多方法,但它并没有真正起作用.
我的问题是我有这个应用程序,我需要更新,更新后,它应该自动重新启动相同的应用程序(更新).
这是我的代码:
private synchronized void runRootUpdate() {
// Install Updated APK
String command = "pm install -r " + downloadPath + apkFile;
Process proc = Runtime.getRuntime().exec(new String[] {"su", "-c", command});
int test = proc.waitFor(); // Error is here.
if (proc.exitValue() == 0) {
// Successfully installed updated app
doRestart()
} else {
// Fail
throw new Exception("Root installation failed");
}
}
private void doRestart() {
Intent mStartActivity = new Intent(context, MainActivity.class);
int mPendingIntentId = 123456;
PendingIntent mPendingIntent = PendingIntent.getActivity(context, …Run Code Online (Sandbox Code Playgroud) android ×1