1

I'm developing an app which needs to send an SMS if / when the device shuts down.

In order to receive the action I'm using android.intent.action.ACTION_SHUTDOWN and android.intent.action.QUICKBOOT_POWEROFF actions, and it works perfectly well. In fact, the method I'm using to send the SMS is also working (as I have used it multiple times in other apps).

The problem I'm facing is that when I receive the SHUTDOWN action the telephony service is already off, so the SMS is unable to be sent and it remains queued waiting for a retry.

Is there a way to prevent / turning on again the telephony service in order to send my SMS?

In case it's not possible, is there another action similar to the SHUTDOWN event which I can use instead?

Grender
  • 1,589
  • 2
  • 17
  • 44

1 Answers1

0

Is there a way to prevent / turning on again the telephony service in order to send my SMS?

You are welcome to make your own customized build of Android that sends an SMS message as part of its shutdown process. Then, you can try to package that customized build of Android into a custom ROM for a particular piece of hardware.

If you are asking whether an app can do that on arbitrary hardware, the answer is no.

is there another action similar to the SHUTDOWN event which I can use instead?

You can ask the user to tap on something related to your app (e.g., a Notification) before shutting down the device.

Otherwise, I am not aware of some other event that not only tells you that the device is shutting down but also lets you block that shutdown process until you decide it is time to proceed (e.g., after sending an SMS, after forcing a ransomware payment).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks for your answer, but the SMS must be send without user interaction. This functionality is part of https://github.com/GrenderG/Protestr app, where there is an option to send an SMS to a contact if your device shuts down during a demonstration (i.e., the police arrests you). – Grender Jun 06 '17 at 11:21
  • @Grender: The police are unlikely to shut down the device, as that decreases their chances of pulling data off of it. If the device is shutting down, as with when the device is starting up (`ACTION_BOOT_COMPLETED`), there are no guarantees about the state of the environment at that point. And if the police are thugs, they are as likely to break the device as to power it down. I suggest that you look into [PanicKit](https://guardianproject.info/2016/01/12/panickit-making-your-whole-phone-respond-to-a-panic-button/). – CommonsWare Jun 06 '17 at 11:27
  • I have experience in demonstrations and, at least, in Spain if you are being arrested the police usually tells you to shut down your device and give it to them (along with everything you carry). Plus, if you know you are going to be arrested it's easy to press the power button and quickly shut down your phone. Btw, I'll give that link a look. – Grender Jun 06 '17 at 11:40
  • @Grender: All that may be true, but it doesn't change the intrinsic nature of Android. – CommonsWare Jun 06 '17 at 11:47