java - How to run a background service periodically with small intervals in android? -


my application has service scans bluetooth device. scan controlled u.i. once turned on, goes on indefinitely needs sleep in between implicitly conserve battery. should do? : 1) asynctask while loop uses sleep(); 2) scheduledexecutorservice 3) handler 4) alarm + bound service + broadcast receivers or what? p.s. - intervals might vary few seconds 1 hour.

should continue scanning when app in background? if so, use alarm started service; if not, use handler in activity.


Comments