-1

i want to restart my android phone by using a simple application which contain a button. By clicking the button my phone should be restart. I am using android studio latest version.

1 Answers1

1

You probably wont be able to do this. You can restart the phone by using

final PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
pm.reboot(null);

However, as far as I am aware, this is only available to system applications.

PPartisan
  • 8,173
  • 4
  • 29
  • 48
  • You'll probably find if you check logcat that the crash is due to not having permission to reboot the phone – PPartisan Nov 16 '19 at 11:37