yayaa / LocationManager

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

[Question] Getting location every second #68

Closed achatina closed 6 years ago

achatina commented 7 years ago

...DEFINE YOUR ISSUE...

Hello! I'm trying to use your library and i stuck a little bit with setting LocationConfiguration. I'm trying to get location every second and show it for user. This is my repository. But it didn't work and I really can't understand why. As you can see in logs, it takes more than 1 minute. And it reset textView only after changing screen orientation (All this time i was walking with WiFi + GPS). Is it a problem with my code in Activity, or I made something wrong with Configurations?

Configuration

@Override
    public LocationConfiguration getLocationConfiguration() {
        return new LocationConfiguration.Builder()
                .keepTracking(true)
                .askForPermission(new PermissionConfiguration.Builder()
                        .requiredPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION })
                        .build())
                .useGooglePlayServices(new GooglePlayServicesConfiguration.Builder()
                        .fallbackToDefault(false)
                        .askForGooglePlayServices(false)
                        .askForSettingsApi(true)
                        .failOnConnectionSuspended(true)
                        .failOnSettingsApiSuspended(false)
                        .ignoreLastKnowLocation(false)
                        .build())
                .useDefaultProviders(new DefaultProviderConfiguration.Builder()
                        .requiredTimeInterval(1000)
                        .acceptableTimePeriod(1000)
                        .requiredDistanceInterval(0)
                        .gpsMessage("Turn on GPS?")
                        .setWaitPeriod(ProviderType.GPS, 10 * 1000)
                        .setWaitPeriod(ProviderType.NETWORK, 10 * 1000)
                        .build())
                .build();
    }

Logs


08-28 01:42:16.882 24672-24672/me.sample I/Location:: 35.2256737 / 47.7800655

08-28 01:43:43.321 24672-24672/me.sample I/Location:: 35.2256682 / 47.7800894

08-28 01:43:43.355 2379-24181/? W/ctxmgr: [AclManager]No 2 for (accnt=account#-1090707797#, com.google.android.gms(10012):UserLocationProducer, vrsn=11302000, 0, 3pPkg = null ,  3pMdlId = null ,  pid = 2379). Was: 2 for 1, account#-1090707797#```
yayaa commented 6 years ago

Hey, sorry for late answer, by the logs i can only tell you that it works as intended. But unfortunately location updates are depending on device itself too. I could only suggest you to try your sample with different devices and check what are the outputs.

One thing about your configurations; if you set .fallbackToDefault(false) on GooglePlayServicesConfiguration you might receive a failure even if you could get the location from default providers.