I have a shutdown receiver and in the event of a shutdown, I want to POST that to my server to track what time the device is shut down. The problem is that by the time the shutdown receiver is triggered, networking is already shut down so there is no way to send the information. I could store the time locally and send upon next bootup but it would be ideal if I could somehow pause the shutdown process until after the information is sent. Is there a way to do this?
Asked
Active
Viewed 429 times
1
-
1Possible duplicate of [Is there any way to receive a notification when the user powers off the device?](http://stackoverflow.com/questions/2190126/is-there-any-way-to-receive-a-notification-when-the-user-powers-off-the-device) – Chefes Apr 28 '17 at 18:27
-
Check this link http://stackoverflow.com/questions/2190126/is-there-any-way-to-receive-a-notification-when-the-user-powers-off-the-device/2190184#2190184 Probably you can consume a web service when you receive a notification. – Chefes Apr 28 '17 at 18:28
-
thnx for your reply. i am successfully able to get shutdown event. but i am facing problem when i sent that event to server.. – Shivanshu Verma Apr 28 '17 at 18:55
-
any suggestions? – Shivanshu Verma Apr 29 '17 at 04:05
-
Well... you could save the shutting down date in SharedPreferences and when the application start over again you send the information to the server. – Chefes Apr 29 '17 at 04:34
-
yes its possible and i am able to do the same as you say. but i need instant flag whenever phone getting shutdown. – Shivanshu Verma Apr 29 '17 at 04:38
-
the another option is use udp connection with the server in that way your phone always will be with session active on server so, when you the phone is shutting down you will send the info to the server. – Chefes Apr 29 '17 at 04:42
-
this is not a good idea to active a connection continously. is their any other way to achieve this? – Shivanshu Verma Apr 29 '17 at 05:29
-
@ShivanshuVerma hii did you get the answer? , i have same situation and i want to sent flag of shutdown before device gets off, not after on restart of device. – shyam002 Apr 04 '18 at 09:34