I would like to programmatically shutdown the users device from within my app. Since I know it is impossible to shut it down directly, I was wondering if there is a way for me to instead show the confirmation dialog box that would show up if you were to press "Power off".
            Asked
            
        
        
            Active
            
        
            Viewed 3,144 times
        
    2
            
            
        - 
                    You could just execute a process using `reboot -p` - but you'd need root access – CodingIntrigue Mar 12 '15 at 12:55
 - 
                    1possible duplicate of [SDK Android : How to open Shutdown/Reboot dialog for the device](http://stackoverflow.com/questions/19930790/sdk-android-how-to-open-shutdown-reboot-dialog-for-the-device) – Rod Mar 12 '15 at 12:55
 - 
                    Possible duplicate of [Simulating power button press to display switch off dialog box](https://stackoverflow.com/questions/11338022/simulating-power-button-press-to-display-switch-off-dialog-box) – Jonas Czech Oct 24 '19 at 19:33
 
2 Answers
1
            
            
        If your app has root access you can run the following as root:
am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN
        Nova Entropy
        
- 5,727
 - 1
 - 19
 - 32
 
0
            
            
        - 
                    I wanted to be able to show the confirm box (Your phone will be shut down, OK / Cancel), how could I do this after stimulating the power off menu – Nick Gable Mar 12 '15 at 13:02
 -