yayaa / LocationManager

Simplify getting user's location for Android
807 stars 187 forks source link

FragmentActivity #7

Closed kkrishnan90 closed 8 years ago

kkrishnan90 commented 8 years ago

Thanks for such an amazing library. Now, I would like to know how can I use your library in a class which already extends FragmentActivity. I actually have a tab with viewpager architecture in which one of the tab receives location updates continuously and moves the marker on the map .. Thanks in advance

yayaa commented 8 years ago

You need to create a locationManager instance by yourself, but ensure to notify it on every required step of your Activity. See LocationBaseActivity

Then i would suggest you to trace location in the activity, then push it into your fragment when received.

rajeevjaiswal commented 8 years ago

@yayaa I need to trigger getlocation method from a fragment. So I extended LocationBaseActivity to the parentActivity of the fragment and implemented the methods. I am calling getLocation methodof the activity from the fragment Which works and I get the location. But how do I pass this location to my current fragment? Otherthan using sharedpreference

yayaa commented 8 years ago

You can use findFragmentByTag to get your fragment's instance and have a public method on it to pass location, or you can set a localBroadcastReceiver to listen a specific action and send that broadcast when you receive location updates, or create a static location field in any class and set / get to that value from anywhere or so on... There are lots of options, pick the one suits you better. @rajeevjaiswal