Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to know device is power off

Tags:

android

I want to do something when the mobile device is closing, but I don't know what is the method; could you tell me how to detect if mobile device is shutting down?
I know the method about mobile restart android.intent.action.BOOT_COMPLETED, but I cannot find similar power off.

like image 638
pengwang Avatar asked Feb 22 '11 09:02

pengwang


People also ask

How do you tell if a phone is powered off?

Press the “Power” button on your cellphone to determine if it is powered off. The display on most cell phones will turn on once the button is pressed. If the phone is locked, the lock screen is displayed.

How do you find a device if it is shut down?

An Android phone can be found through the Android Device Manager. To find your phone, simply go to the Find My Device site and log in using the Google account that is associated with your phone. If you have more than one phone, choose the lost phone in the menu at the top of the screen.

Can a phone be detected if turned off?

Can a phone be tracked if it's turned off? A phone that is turned off is difficult to track because it stops sending signals to cell towers. However, the service provider or internet provider can show the last location once it's switched back on.

What happens when your phone is turned off?

Shutting off your phone will clear any apps that are running in the background and get rid of anything that's draining your battery. Shutting down your phone can also help solve network connectivity problems. Smartphones will occasionally lose connection with your mobile network.


1 Answers

http://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN

public static final String ACTION_SHUTDOWN

Since: API Level 4 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.

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

This would appear to be it? I just Googled your command and it was on the Standard Broadcast Actions list. :)

like image 86
Codemonkey Avatar answered Sep 30 '22 17:09

Codemonkey