Search code examples
androidrestart

Android - How to restart system_process programmatically?


I have an android device, which runs my app as system app. In this app there is an update function, which download the new version of the apk from the internet and then overwrites the apk on the device. After that I need to restart the application... and this is my problem, I have tried many ways:

finish();

Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName() );   
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK );
startActivity(i);

System.exit();

android.os.Process.killProcess(pid);

I noticed that if I stop the system_process in Eclipse, my devices is restarting, app is upgrading and the new version of my app is running. So my question is, how can I stop/restart system_process programmatically? Or have you got any good idea to restart and run my new versioned app? Thx :)


Solution

  • Thx. It does the magic! :)

    PowerManager pm = (PowerManager) this.getApplicationContext().getSystemService(Context.POWER_SERVICE);
    pm.reboot("bootloader");