views:

39

answers:

1

Hi all,

In my app I want to obtain a gps lock and record the coords. But I do not want to lock the device into looking for the gps. The user is to be free to traverse through the app and the different activities within.

So If I call a locationListener in activity A, can I reference it in activities B C and D?

if is was still in activity A I could say something like

A.this.mlocListener.removeMyUpdates();

When I am in activity B how can I reference the LocationListener I set up in Activity A

Thanks in advance

Kevin

A: 

No. Set up a broadcast when you have a location event you want the other activities to see. Or user a service to do the locationlistener and then you can bind to it. Keep in mind that you should unregister locationlisteners in your onPause() method if you're using it in an activity. It will drain the user's battery

Falmarri
Thanks for that, was able to implement it as a service (after a lot of stumbling around in the dark!)Answer accepted.
Kevin Bradshaw