My requirement is send a request to the server with mobile switch on/off status and update the mongodb
database mobile switch on/off status.
To do this I am using an Service
. In my Service
onCreate
method I added the code to send a request with switch on status and update database. It is working properly. I need to send switch off status when mobile switched off and that code part I added to Service onDestroy
method. But it is not working , at least Service onDestroy
method is not calling when mobile switch off.
Can Anyone give me the solution for that and How to I send a request from Service
when Mobile switched off ?