1

I am using SHUTDOWN intent filter to detect when phone is getting shutdown and registered a receiver with SHUTDOWN intent filter in manifest file.

In onReceive method I am starting a http call on different thread , but http call is not happening because by some way it is not getting internet or WIFI and GPRS engine is getting switched off during shutdown,

Is there any way to do HTTP call successfully during phone shutdown?

I was thinking to hold shutdown for few seconds once Http call is successful then shutdown the phone , is it possible to do that ?

Naga
  • 1,931
  • 4
  • 25
  • 42

1 Answers1

1

This is quite impossible, you cannot postpone shutdown signal until your request is executed. As you have experienced there are no particular order on which the phone features will be shutdown and you can gamble wither your call will successfully be executed.

What you can to conclude shutdown event by flagging SHUTDOWN intent has been received and maybe executed the http call when ACTION_REBOOT intent is called when the device is powered back, let's say after some threshold (delta time 2 min e.g) which determines if the phone was shutdown or rebooted.

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
  • Okay , thanks for suggestion. so there is no way to inform server that phone is shutdown ?. I was thinking to store shutdown timestamp in db and sending it to server on reboot. – Naga Oct 06 '15 at 19:02
  • Simple write for the timestamp in the SharedPrefs will do the trick. – Nikola Despotoski Oct 06 '15 at 19:03