2

i want to Reboot my phone i tried

        try {
    Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" });
    proc.waitFor();
} catch (Exception ex) {
    Log.i(TAG, "Could not reboot", ex);
}

and also PowerManager see my coding but device is not rebooting in both the coding kindly give working code

          ok = (Button)findViewById(R.id.button1);
    final PowerManager power = (PowerManager)getSystemService(Context.POWER_SERVICE);

    ok.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            power.reboot("fav");
        }
    });
Ronak Mehta
  • 5,971
  • 5
  • 42
  • 69

2 Answers2

3

You cannot do a reboot from an ordinary SDK application. Only applications signed with the system firmware signing key can do this.

Copied from this answer, Programmatically switching off Android phone

Community
  • 1
  • 1
Mudassir
  • 13,031
  • 8
  • 59
  • 87
  • 2
    You need the system key to sign your app. See this post for details; http://stackoverflow.com/questions/3598662/how-to-compile-android-application-with-system-permissions – Mudassir Feb 13 '12 at 09:50
1

I've been able to programatically reboot on a custom device via just placing the application in /system/app instead of /data/app, not signing it with the same key I used to build Android.
It may also work on a rooted device.
If you want it to work on any device where your application is installed through normal means, it can't be done as you can't sign it with system keys for every device.

Torp
  • 7,924
  • 1
  • 20
  • 18