I am creating app(only for Android 6) in which I have to give reboot functionality using button click. I am using following code:
PowerManager pm =(PowerMan
This is my answer and code that might help you:
if (ContextCompat.checkSelfPermission(this, Manifest.permission.REBOOT)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.REBOOT}, 1);
if(ContextCompat.checkSelfPermission(this, Manifest.permission.REBOOT)
!= PackageManager.PERMISSION_GRANTED) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
pm.reboot(null);
}
} else {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
pm.reboot(null);
}