android - Is there any way to receive a notification when the user powers off the device? -
I should know that when the user closes his phone, is there a spread (or similar) that indicates that when The user's phone stops?
You can use the broadcast that is broadcast when the phone is broadcasted :
The app will not normally need to handle it, as the foreground activity will also be paused.
In other words, if you properly respond to all lifecycle incidents for your activity, there is no need to use it unless you actually have something related to closing Do not want to be specific.
In the API, the code
You will trap the transmission with one. This will look something like this:
Close the public class The receiver expands Broadcast receivers {@ Override Public Zero recipient (References Context, intent of intent) {// insert code}}
You will need an entry like this in your manifest:
& lt ; Receiver Android: name = ". ShutdownReceiver" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.intent.action.ACTION_SHUTDOWN" /> & Lt; / Intent-Filter & gt; & Lt; / Receiver & gt;
Depending on what you are doing, you have to use another option which is sent when the phone is restarted.
Comments
Post a Comment