Title: Events turning off the device in android
Tags: android;events
Question: My question is if exist some  event before turning off cell phone in android.
For example  moments before turning off the device send an alert.

Here is the accepted answer: You can listen for Intent.ACTION_SHUTDOWN:
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.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:09/29/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<android><events>', 'Title': 'Events turning off the device in android', 'ViewCount': 70, 'id': 26105710, 'user_AboutMe': None, 'user_AccountId': 5102884.0, 'user_DisplayName': 'Jaciel Hernandez', 'user_Reputation': 3.0, 'user_Views': 1.0, 'user_id': 4091954.0}}