DEV Community

gaurawkumartechstern
gaurawkumartechstern

Posted on

Restart android device android 5.1

how to restart android device programmatically and I used below code for restart my device Process proc = null;

try {

           //proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" });
             proc = Runtime.getRuntime().exec(new String[]{"/system/bin/su","-c","reboot now"});
            proc.waitFor();
        } catch (Exception ex) {
            Log.i(TAG, "Could not reboot", ex);
        }
Enter fullscreen mode Exit fullscreen mode

And he is asking for a permission then i used this code

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

please help me and inform me it is possible or not and i need this only in android 5.1

Top comments (1)

Collapse
 
gaurawkumartechstern profile image
gaurawkumartechstern

Is it possible