Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect the device is shutting down?

In my android application i need to do some action if the device is turning off suddenly. Is there any way to detect the device is shutting down?

like image 888
Nithin Michael Avatar asked Dec 11 '13 08:12

Nithin Michael


1 Answers

Broadcast Action: Device is shutting down. This is broadcast when the device is being shut down (completely turned off, not sleeping). Once the broadcast is complete, the final shutdown will proceed and all unsaved data lost. Apps will not normally need to handle this, since the foreground activity will be paused as well.

This is a protected intent that can only be sent by the system.

May include the following extras:

EXTRA_SHUTDOWN_USERSPACE_ONLY a boolean that is set to true if this shutdown is only for userspace processes. If not set, assumed to be false. 

Constant Value: "android.intent.action.ACTION_SHUTDOWN"

Intent | Android Developers.

You have to configure the broadcast receiver to listen for this.

like image 131
Triode Avatar answered Oct 20 '22 03:10

Triode