Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top