0

I stuck in one problem.i got one user location tracking example from Here.I test this app lot of time during travelling. when the i started an application and during travelling i am handling android phone(means doing any work on device) then it getting tracking user location every 30 second. its fine for me. But during travelling if i locked my device kept in a pocket and after reached at destination then i checked the application latitude,longitude listing it was missing the traveled location lat-long coordinates. every 30 second listed data(lat-long) in list means AlarmManager working fine. The problem is the location does not change during travelling getting same location during travellingwhere i locked my device.If i will wake up the device during travelling anywhere then immediately it will take latest location(lat long). .Don't know exactly what happening and what is the problem.I tried WakefulIntentService. Please help me. Thank you in Advance.

Amol Sawant
  • 13,842
  • 2
  • 20
  • 27

1 Answers1

0

In AlarmManager.setRepeating() Set type to ELAPSED_REALTIME_WAKEUP or RTC_WAKEUP so it will run if the device sleeps.

Then when the alarm event is fired and received by a BroadcastReceiver you will have to create, you could request for updates and handle other events.

  • Hello Keerthana, thank you for rpl. I used a same. AlarmManager working fine during sleep mode. The problem location does noy change during device sleep. Means when I locked device the same location during and after when I reached samewhere and unlock device then it will take the updated location. Please let me know if u have any solution for this. Thank you in advance... – Amol Sawant Aug 06 '13 at 16:04
  • GPS update cannot be done when the phone is locked. So, whenever an alarm event is fired, force the phone to wake and update the GPS location. look [http://stackoverflow.com/questions/3579027/android-periodically-wake-up-from-standby-mode] for periodically waking phone from sleep mode. – keerthana murugesan Aug 07 '13 at 08:19
  • Hello Keerthana, Thank you. I used FULL_WAKE_LOCK then it working fine for me but it will turn on screen every 30 second and update the location. i also tried to use PARTIAL_WAKE_LOCK to keep screen off and only to wake up CPU so it not working for me means not updating location in background. Please help me i stuck here from last 1 week. Thank you in advance. – Amol Sawant Aug 09 '13 at 05:49
  • have you requested the android.permission.WAKE_LOCK permission in an element of the application's manifest.? – keerthana murugesan Aug 12 '13 at 11:15