0

I'm running a thread from a service where i'm listening for changers in the acceleronometer every 3 seconds. So i run the listener in a while loop with Thread.sleep(3000). But it tends to work with shorter duration. But in longer run it seems to get crash the whole application.

Any suggestions?

dinesh707
  • 12,106
  • 22
  • 84
  • 134

3 Answers3

0

You should look into using an IntentService instead, It is the same thing as a service except that it will run off of the main UI thread. Otherwise there should not be a problem that i know of. Services are suposed to be long running.

Emil Sjölander
  • 1,773
  • 4
  • 19
  • 27
0

you should use alarm for the time tracking and brodcast reciever.

Ravi Bhojani
  • 1,032
  • 1
  • 13
  • 24
0

I used AsyncTask, and problem of crashing threads fixed.

dinesh707
  • 12,106
  • 22
  • 84
  • 134