I am trying to develop a application in android that consists a service to read the sensor value for multiple hours. When i start the service my device get hang and all the othe
I think the answer to this problem lies in the power of IntentService
. IntentService is a subclass of the regular Service class. There are a few key differences, however.
Now, here's how you can take IntentServices to your advantage: IntentServices do not run on the main thread. Instead, they run on separate "Worker threads". This single attribute would solve your problem and eradicate the ANRs you are currently facing.
To learn more about the differences between services and IntentServices, check this out.