views:

48

answers:

1

hi. here is my problem.

i have an application that has a tabActivity and 3 tabs. all off the tabs use a location listener and work with locations. i implement onPause and onResume for every tab to remove and start listening for location accordingly. is this the right way to go? i had another idea to work with and that was implementing a location listener to the tabActivity and doing broadcasts to the child tabs with the location, but it seemed more complicated.

the problem with my current solution is that whenever i switch tab i lose the location i got in the previous and i cant use getlastknown location because i dont want the last location on start of the application.(does this make sense?) what can i do to solve this problem.

a thing that will work better will be to have one variable that will hold the last location from the onLocationChanged and i can observe its changes and call methods onChange.

are there any suggestions about my issue, maybe some tutorials,examples, anything that might work. tnx

A: 

i had another idea to work with and that was implementing a location listener to the tabActivity and doing broadcasts to the child tabs with the location

You could definitely do that. Or, you can implement a service which each of the 3 tabs bind to, though you'd probably still need to send broadcasts. Doing broadcasts really isn't all that complicated. Just register/unregister each broadcast receiver in each tab's onresume/onpause

Falmarri
any example or tutorial that you can suggest? i couldn't find anything good so far.
DArkO
ok i have done it. tnx for the help.
DArkO