I have to compare my location with the stored location in DB regularly after 30 seconds in my app. Please tell me which one is the best way to implement and less power consumption.
Asked
Active
Viewed 176 times
-2
-
you could use broadcast receiver. – Vishal Sanghani Nov 30 '16 at 09:30
-
1It doesn't matter ... as the main problem in battery draining would be GPS and CPU always on – Selvin Nov 30 '16 at 09:36
1 Answers
0
i would suggest HandlerThread
or IntentService
as it wont restrict your UI/Main thread.
This video should help you clear your doubts https://www.youtube.com/watch?v=0Z5MZ0jL2BM
one not so efficient approach can be to use AlarmManager to schedule at callback very 30 secs ,on such callback perform ur task,they wont keep your resource awake when u r just waiting for next process step

Ak9637
- 990
- 6
- 12
-
-
@selvin , please correct me if i m mistaken , Handler thread would affect UI thread only when it is created or need to deliver something to the UI thread,other time it would be independent – Ak9637 Nov 30 '16 at 09:39
-
-
@Selvin ,totally agreed with ur view, in current scenerio would alarm manager or Scheduler be a good approach – Ak9637 Nov 30 '16 at 10:08