Is there a way to reboot a device with phonegap/cordova? How would I go about doing this? I think it may not be possible on an ipad/iphone but it would be on androids.
2 Answers
First basically it can't be done unless your device is rooted/jailbreaken (depending are we talking about Android or iOS).
Now comes the fun part even if you have rooted/jailbreaken device you will not be able to do that unless you can do some Java/Objective C development.
Basically Phonegap plugin don't exist simply because this functionality is usually not needed unless you are doing something with your phone on a basic level. But if you have enough knowledge you can do it by your self. Phonegap plugin can be created very easy, and you can find more in this tutorial. What you want to do is create a simple plugin that will execute Java/Objective C code when you need it.
Android/Java example :
try {
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" });
proc.waitFor();
} catch (Exception ex) {
Log.i(TAG, "Could not reboot", ex);
}
iOS/Objective C example
Unfortunately I don't have that much experience with this functionality on iOS so you will need to trust this answer.
-
2Thanks!! Android was what I had in mind. I was a bit unsure on IOS due to the requirement of being jailbroken but Ill give it a go :) – Tarang May 05 '13 at 06:57
I needed same functionality, made a plugin based on Gajotres example: cordova-plugin-reboot

- 552
- 6
- 11