Azuu
Azuu

Reputation: 856

Location tracking in background in android

I am working on an application which fetch the location details in a periodic manner.. i have tried service and broadcastreciever but failed to achieve the location details in particular time frame say 30mins or so.. can any help or suggest me some thing through which i can achieve the location details again and again .. Thnks in adv

Upvotes: 2

Views: 3809

Answers (1)

Mukund Samant
Mukund Samant

Reputation: 1089

Have you tried using the Alarm Manager? You can do the following to update location periodically:

1.Register an alarm manager that will call a service every 30 mins.

2.Make sure you acquire a wake lock so that the device wakes up from sleep.

3.The alarm manager takes a pending intent which in turn calls a BroadcastReciever/Service when the alarm is triggered.

4.From this BroadCastReciever call the Service to that will update your location. Check this question for the complete code.Also this.

Upvotes: 2

Related Questions