简体   繁体   中英

Is it possible to reboot both rooted & unrooted android device Programmatically?

In my android application, I wanna restart my android device on button click. But its working in rooted Phone,but not in un rooted phone.

try {
               Runtime.getRuntime().exec(new String[]{"su","-c","reboot now"}));

                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

Is it possible to reboot both rooted & unrooted android devices?

Unless something has changed recently you cannot reboot a non-rooted phone programatically, from a regular application.

You can do it if the application is signed by the system firmware key (which a regular application won't be).

If you do go the rooted device route, then be aware that the runtime exec function has some characteristics that mean it may not always behave as you expect.

Rather than learning this the hard way there is an excellent summary here: http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM