yayaa / LocationManager

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

Possible to change LocationConfiguration on runtime #41

Closed pmsferreira closed 7 years ago

pmsferreira commented 7 years ago

Hi friend,

With the new library update, we must provide a LocationConfiguration details in initial app creating (I guess is like that) but in some parts in my app I need to use a different LocationConfiguration details (ask for permissions or not, for example), it is possible ?

Thanks, Pedro Ferreira

yayaa commented 7 years ago

Hey @pmsferreira, You don't need to create your configuration object on app initialization, you can create different configurations.

With new version of the library, configuration is like a contract to ask for permission. That is why it is not possible to change on runtime. But you can define different configuration objects for different usecases and initialize LocationManager with required configuration. That depends on how do you implement.

If you have multiple activity to provide different configurations, then you can extend LocationBaseActivity and provide required configuration. But if you need to provide different configurations in same activity then you need to create your own implementation and adapt the behaviour when you need to change the configuration. You can create new LocationManager with different configuration, but don't forget to cancel first location request.

Best, Yahya