JohnC Expert Licensed User Longtime User Jun 30, 2014 #1 I need to be able to programmically reboot an android device. I found two solutions at stack overflow: http://stackoverflow.com/questions/4966486/reboot-the-phone-on-a-button-click But the above solution requires a "system" signing key. Another solution looks doable, but I don't know how to convert to VB: http://stackoverflow.com/questions/4580254/android-2-2-reboot-device-programmatically B4X: try { Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" }); proc.waitFor(); } catch (Exception ex) { Log.i(TAG, "Could not reboot", ex); } Anyone know how to convert the above for use in B4A?
I need to be able to programmically reboot an android device. I found two solutions at stack overflow: http://stackoverflow.com/questions/4966486/reboot-the-phone-on-a-button-click But the above solution requires a "system" signing key. Another solution looks doable, but I don't know how to convert to VB: http://stackoverflow.com/questions/4580254/android-2-2-reboot-device-programmatically B4X: try { Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" }); proc.waitFor(); } catch (Exception ex) { Log.i(TAG, "Could not reboot", ex); } Anyone know how to convert the above for use in B4A?
NJDude Expert Licensed User Longtime User Jun 30, 2014 #2 That code will work on ROOTED devices only. By the way is not VB but B4A Upvote 0
JohnC Expert Licensed User Longtime User Jun 30, 2014 #3 Understood - the devices my app is designed for are all rooted (RikoMagic MK802IV, ect). Upvote 0
JohnC Expert Licensed User Longtime User Jun 30, 2014 #5 That example looks like it could be related (if ".Shell" = ".exec") But it still requires a decent amount of syntax conversion to go from A to B that I don't know how to do. Upvote 0
That example looks like it could be related (if ".Shell" = ".exec") But it still requires a decent amount of syntax conversion to go from A to B that I don't know how to do.
NJDude Expert Licensed User Longtime User Jun 30, 2014 #6 Give this code a shot: B4X: Private p As Phone Private Out, Err As StringBuilder Out.Initialize Err.Initialize File.WriteString(File.DirRootExternal, "reboot.sh", "su -c reboot") p.Shell("sh", Array As String(File.Combine(File.DirRootExternal, "reboot.sh")), Out, Err) Upvote 1
Give this code a shot: B4X: Private p As Phone Private Out, Err As StringBuilder Out.Initialize Err.Initialize File.WriteString(File.DirRootExternal, "reboot.sh", "su -c reboot") p.Shell("sh", Array As String(File.Combine(File.DirRootExternal, "reboot.sh")), Out, Err)
JohnC Expert Licensed User Longtime User Jul 1, 2014 #7 That worked! Sweet. It would have taken me hours with trial and error to figure out that syntax. Thanks! Upvote 0
That worked! Sweet. It would have taken me hours with trial and error to figure out that syntax. Thanks!