Naga
Naga

Reputation: 2021

HTTP call during phone shutdown

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 ?

Upvotes: 1

Views: 111

Answers (1)

Nikola Despotoski
Nikola Despotoski

Reputation: 50538

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.

Upvotes: 1

Related Questions