yayaa / LocationManager

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

ACCESS_BACKGROUND_LOCATION example? #120

Closed icyield closed 1 year ago

icyield commented 3 years ago

Thanks for the library.

Have you an example of using the library to allow ACCESS_BACKGROUND_LOCATION?

yayaa commented 2 years ago

Have you tried within a service / workmanager with a configuration something link the following?

LocationConfiguration awesomeConfiguration = new LocationConfiguration.Builder()
    .keepTracking(true)
    .askForPermission(
         new PermissionConfiguration.Builder()
             .requiredPermissions(
                  new String[] { permission.ACCESS_FINE_LOCATION, permission.ACCESS_BACKGROUND_LOCATION }
             )
        .build()
     )
    .useGooglePlayServices(new GooglePlayServicesConfiguration.Builder().build())
    .useDefaultProviders(new DefaultProviderConfiguration.Builder().build())
    .build();
yayaa commented 2 years ago

Happy to accept PR for the example if you build :)