0

I am making an android app, in which the app must launch just before the phone is shutting down. Is that possible?

Here i am not talking about encountering phone shutdown event when my app is running.

Vipul Behl
  • 644
  • 1
  • 7
  • 20

1 Answers1

0

You will need this permission in your manifest file

<uses-permission android:name="android.permission.DEVICE_POWER" />

And you will listen to the intent like this

<receiver android:name=".ShutdownReceiver">
    <intent-filter>
        <action android:name="android.intent.action.ACTION_SHUTDOWN" />
    </intent-filter>
</receiver>

You can look at the links here for some description and here for official documentation.

I don't know the exact application where you want to use it, but you can have a background service running with the receiver for this intent.

Community
  • 1
  • 1
Codester
  • 193
  • 6