yayaa / LocationManager

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

Can't get location when phone is indoors (in building) #124

Open LugovayaOksana opened 2 years ago

LugovayaOksana commented 2 years ago

I don't have google services on my phone. So I am trying to use useDefaultProviders. When the phone is in the building, I can't get the coordinates. When I go outside with my phone, I get the coordinates.

My settings for useDefaultProviders

val acceptableTimePeriod = 50L val requiredTimeInterval = 50L val requiredDistanceInterval = 15L val acceptableAccuracy = 1000.0f val setWaitPeriodGPS = 20 1000L val setWaitPeriodNetwork = 20 1000L

val awesomeConfiguration = LocationConfiguration.Builder() .keepTracking(true) .useGooglePlayServices( GooglePlayServicesConfiguration.Builder() //.locationRequest(YOUR_CUSTOM_LOCATION_REQUEST_OBJECT) .fallbackToDefault(true) .askForGooglePlayServices(false) .askForSettingsApi(true) //.failOnConnectionSuspended(true) .failOnSettingsApiSuspended(false) .ignoreLastKnowLocation(false) .setWaitPeriod(20 * 1000) .build() ) .useDefaultProviders( DefaultProviderConfiguration.Builder() .acceptableTimePeriod(acceptableTimePeriod) .requiredTimeInterval(requiredTimeInterval) .requiredDistanceInterval(requiredDistanceInterval) .acceptableAccuracy(acceptableAccuracy) //.gpsMessage("Turn on GPS?") //.gpsDialogProvider(YourCustomDialogProvider()) .setWaitPeriod(ProviderType.GPS, setWaitPeriodGPS) .setWaitPeriod(ProviderType.NETWORK, setWaitPeriodNetwork) .build() ) .build()

    locationManager = LocationManager.Builder(applicationContext)
        //.activity(this) // Only required to ask permission and/or GoogleApi - SettingsApi
        .configuration(awesomeConfiguration)
        .notify(MyLocationListener())
        .build()

    locationManager?.get()

Logs

In the logs, I see that the provider is asked GETTING_LOCATION_FROM_NETWORK_PROVIDER

Please tell me why I can't get the coordinates when the phone is indoors? If it is possible to get it, then how to do it without Google services? Thanks in advance.