I’m new on Android developing.
I’m trying to manage gps location between activity. In particular I have created a thread, started with main activity, that update after a few interval the gps position and save the new position into a shared Bean.
Now, when I pass as extras the Bean to the next activity, I can get the last value of the bean but, the bean on the new activity isn’t updated by the thread. I don’t create a new Bean, and for this reason I think that the update of the bean would be seen on the new activity.
There is the code that I use to retrieve the extra in the new activity:
ShareBean pos;
Intent intent = getIntent();
Bundle extras = getIntent().getExtras();
if (extras != null)
{
pos = (ShareBean)intent.getSerializableExtra("Location");
}
Any help is appreciate.
Thanks in advances.
Simone
you should probably use the
LocationManagerobject to get and access Location updates. You can query it for the last known location for a quick update.The key things is, I ask the location manager to start listening and then from there I can ask for quick updates anytime. I store the updated location information in my
ApplicationContextobject (which I callappModellocally) which is persistent throughout the life of the object.I use the
LocationManagerlike this:Start listening looks like this:
You location listener could look like this:
Good luck!