Giter VIP home page Giter VIP logo

locationmanager's People

Contributors

branoh avatar bryant1410 avatar fdnhkj avatar hayahyts avatar stetro avatar victor-denisenko avatar yayaa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

locationmanager's Issues

Fetching location every second

I have set a custom configuration but location keeps getting updated every second and that too same location.

Configuration

 /**
     * Returns a LocationConfiguration which tights to default definitions with given messages. Since this method is
     * basically created in order to be used in Activities, User needs to be asked for permission and enabling gps.
     */
    public static LocationConfiguration defaultConfiguration(@NonNull String rationalMessage, @NonNull String gpsMessage) {
        return new LocationConfiguration.Builder()

                .askForPermission(new PermissionConfiguration.Builder().rationaleMessage(rationalMessage).build())
                .useGooglePlayServices(new GooglePlayServicesConfiguration.Builder().fallbackToDefault(true)
                        .askForGooglePlayServices(false)
                        .askForSettingsApi(true)
                        .failOnConnectionSuspended(true)
                        .failOnSettingsApiSuspended(false)
                        .setWaitPeriod(10 * 1000)
                        .ignoreLastKnowLocation(true).build())
                .useDefaultProviders(new DefaultProviderConfiguration.Builder()
                        .gpsMessage(gpsMessage)
                        .requiredTimeInterval(10 * 1000)
                        .acceptableTimePeriod(10 * 1000)
                        .requiredDistanceInterval(2 * 1000)
                        .setWaitPeriod(ProviderType.GPS, 5 * 1000)
                        .setWaitPeriod(ProviderType.NETWORK, 5 * 1000).build())
                .keepTracking(true)
                .build();
    }

Logs

PLEASE SHARE YOUR LOGS

08-15 15:19:22.016 15689-15689I/Location Changed: Location Changed - 28.45949666666667 : 77.02664166666666
08-15 15:19:23.012 15689-15689/I/Location Changed: Location Changed - 28.45949666666667 : 77.02664166666666
08-15 15:19:24.012 15689-15689/Location Changed: Location Changed - 28.45949666666667 : 77.02664166666666
08-15 15:19:25.020 15689-15689/Location Changed: Location Changed - 28.45949666666667 : 77.02664166666666

As you can see onLocationChanged is firing at every second.
Is this a bug or is there something wrong with my configuration ?

[Question] Getting location every second

...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#```

change text of "update google play service" dialog

hi
at first thank you for your great job.
it's awesome.

i run my application and a dialog pop up that say , "update your google play service" with an "update" button.

how to change text of this dialog ?

sorry for my bad English.

A BaseLocationListener class would be nice

It would be nice to have a BaseLocationListener class with empty implementations of LocationListener.

It would make code cleaner when we only want to implement 1 oder 2 methods of the LocationListener interface.

We could then write

.notify(new BaseLocationListener() {
    public void onLocationChanged(Location location) {
        // do something with location.
    }
})

Support of API level < 14

i have working app , and just like to integrate this gorgeous library , but i think it require api 14 , can it be supported for lower than that devices ?

Marshmallow Timeout

Hi, awesome library I like the clean code but I have a problem with Marshmallow devices. I just can't make it work, always throws failType = 5.

I have all the permission in the manifest.

Thanks.

How to check if user turned on location?

In my app we allow user to use with or without location. When user turn it off, we load generic data items, and if they turned on we want to get user location before loading data item nearby.

Is there anyway to quickly check if user turned on location settings or we have enough information to get user location?

Possible to change LocationConfiguration on runtime

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

Needs to fail/warn when permissions aren't defined below Android 6.0

Had an issue where ACCESS_FINE_LOCATION was enabled, and Android devices above 6.0 were able to ask for permissions and work correctly, but below Android 6.0, it would step in and ask for permissions, but try to use ACCESS_COARSE_LOCATION and silently fail with not feedback from the library.

onPermissionGranted not called

First off, this project is excellent! It has saved me a ton of time, so thank you for that.

I'm having an issue with onPermissionGranted not being called when I choose "Allow" in the permission dialog.

onPermissionGranted is called the second time I call locationManager.get(), but that method is not called the first time I call locationManager.get(), when the user taps "Allow" on the dialog.

Does this look like a bug to you, or am I doing something wrong?

I'm using version 2.0.3.

The complete code is here: https://github.com/rmtheis/LocationManagerTestApp

Configuration

        LocationConfiguration locationConfiguration = new LocationConfiguration.Builder()
                .askForPermission(new PermissionConfiguration.Builder().rationaleMessage("rationale...").build())
                .useGooglePlayServices(new GooglePlayServicesConfiguration.Builder().build())
                .useDefaultProviders(new DefaultProviderConfiguration.Builder().gpsMessage("gps").build())
                .build();

        locationManager = new LocationManager.Builder(getApplicationContext())
                .activity(this)
                .configuration(locationConfiguration)
                .notify(this)
                .build();

Logs

06-18 16:54:07.093 12234-12234/com.rmtheis.locationmanagertestapp I/DefaultPermissionProvider: Should show rationale dialog for required permissions: false
06-18 16:54:07.093 12234-12234/com.rmtheis.locationmanagertestapp I/DefaultPermissionProvider: Asking for Runtime Permissions...
06-18 16:54:07.114 12234-12234/com.rmtheis.locationmanagertestapp I/LocationManager: Waiting until we receive any callback from PermissionProvider...

How get location when app close or not active?

I'm using BroadcastReceiver (see: SampleService). However, when the application is closed or inactive (enabled, but running in the background), the coordinates are not determined. I tried to comment out the line with unregisterReceiver, but it did not help.

@Override
protected void onPause() {
    super.onPause();
//    unregisterReceiver(broadcastReceiver);
}

Allow distance to be set when keepTracking(true)

It looks like a 0 being passed for distance when getting updates. This allows onLocationChange to keep firing even when location.distanceTo(oldLocation) == 0.0F. For now I will calculate the distance but this seems like a lot of radio usage.

The following line is passing in 0 for distance setting

currentUpdateRequest = new UpdateRequest(provider, timeInterval, 0, locationChangeListener);

https://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener)

method useOnlyGPService not acting right behavior as document says

useOnlyGPService documentation:

While this is set true default location providers (GPS & Network)
 will not be used to receive location, set false if you want them to be used.

but actually it been using for check whether to use GooglePlay service instead of GPS service
https://github.com/yayaa/LocationManager/blob/master/library/src/main/java/com/yayandroid/locationmanager/LocationManager.java#L249

and there's another method for decide whether to use GooglePlay service doNotUseGooglePlayServices

Stop onResume location updates

Hello, great library for avoiding all Google Api client boilerplate code.
Is there currently a way to stop onResume location updates?And if not, Is there a chance that you could add an option to disable that?

Prioritize GPS providers

Hi,
First of all thanks for this great library,
I was wondering if there is a way to prioritize gps providers , for example I want to first use GPS and try to retrieve an accurate position with a 30 seconds timeout and only if it failed use Google Play services and then the network provider.
If the answer is Yes how can I find out which provider has given me the location?
Thanks

Time interval not work

@OverRide
public LocationConfiguration getLocationConfiguration() {
return new LocationConfiguration.Builder()
.keepTracking(true)
.askForPermission(new PermissionConfiguration.Builder().build())
.useGooglePlayServices(new GooglePlayServicesConfiguration.Builder()
.askForGooglePlayServices(true)
.askForSettingsApi(true)
.failOnConnectionSuspended(true)
.failOnSettingsApiSuspended(false)
.ignoreLastKnowLocation(false)
.setWaitPeriod(10 * 1000).build())
.useDefaultProviders(new DefaultProviderConfiguration.Builder()
.requiredTimeInterval(10 * 1000)
.requiredDistanceInterval(1)
.acceptableAccuracy(5.0f)
.acceptableTimePeriod(10 * 1000)
.gpsMessage("Turn on GPS?")
.setWaitPeriod(ProviderType.GPS, 10 * 1000)
.setWaitPeriod(ProviderType.NETWORK, 10 * 1000).build())
.build();
}

I am using above code for update location 10 sec and 1-meter time and distance interval but it always updates after 1 minute.

NPE on googleApiClient

Hi,

I am using this library in production and am unable to repro this on my devices but am getting this exception on many different users devices, I have error reporting through crashlytics and this is my highest crash.

Stack Trace:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.location.LocationAvailability.isLocationAvailable()' on a null object reference
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.getLocationAvailability(SourceFile:100)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationProvider.checkLastKnowLocation(SourceFile:196)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationProvider.onConnected(SourceFile:105)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.onConnected(SourceFile:110)

I am extending LocationBaseActivity and my Location Configuration is:

@Override
public LocationConfiguration getLocationConfiguration() {
return new LocationConfiguration.Builder().askForPermission(new PermissionConfiguration.Builder().build())
                .useGooglePlayServices(new GooglePlayServicesConfiguration.Builder()
                        .askForGooglePlayServices(true)
                        .setWaitPeriod(5 * 1000)
                        .build())
                .useDefaultProviders(new DefaultProviderConfiguration.Builder()
                        .acceptableTimePeriod(2 * 60 * 60 * 1000)
                        .setWaitPeriod(ProviderType.GPS, 10 * 1000)
                        .setWaitPeriod(ProviderType.NETWORK, 5 * 1000)
                        .gpsMessage("Would you mind to turn GPS on?").build())
                .build();
    }

After users on the app login to their account, I check location using:
getLocation(); inherited from LocationBaseActivity

Could you please add a null check to
com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.getLocationAvailability(SourceFile:100) for variable googleApiClient

Doesn't work from a bottomsheetfragment if it needs to request permission

When it tries to request permissions, nothings shows up, and the window is leaked

E/WindowManager: android.view.WindowLeaked: Activity com.XXXXX.main.MainActivity has leaked window com.android.internal.policy.PhoneWindow$DecorView{5864a01 V.E...... R....... 0,0-1440,526} that was originally added here
                                                                      at android.view.ViewRootImpl.<init>(ViewRootImpl.java:368)
                                                                      at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:299)
                                                                      at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
                                                                      at android.app.Dialog.show(Dialog.java:319)
                                                                      at com.yayandroid.locationmanager.helper.PermissionManager.requestPermissions(PermissionManager.java:93)
                                                                      at com.yayandroid.locationmanager.helper.PermissionManager.requestPermissions(PermissionManager.java:63)
                                                                      at com.yayandroid.locationmanager.LocationManager.askForPermission(LocationManager.java:265)
                                                                      at com.yayandroid.locationmanager.LocationManager.get(LocationManager.java:210)
                                                                      at com.yayandroid.locationmanager.LocationManager.get(LocationManager.java:182)

Permissions issue

Hi,

I have had 20 different client devices crash on various device manufacturers with error:

Client must have ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to perform any location operations.
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.requestLocationUpdate(SourceFile:96)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationProvider.requestLocationUpdate(SourceFile:227)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationProvider.onResult(SourceFile:160)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.onResult(SourceFile:131)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.onResult(SourceFile:26)

I have all the necessary permissions in manifest:

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature android:name="android.hardware.location.gps" />

And my location configuration:

return new LocationConfiguration.Builder().askForPermission(new PermissionConfiguration.Builder().build())
                .useGooglePlayServices(new GooglePlayServicesConfiguration.Builder()
                        .askForGooglePlayServices(true)
                        .setWaitPeriod(5 * 1000)
                        .build())
                .useDefaultProviders(new DefaultProviderConfiguration.Builder()
                        .acceptableTimePeriod(2 * 60 * 60 * 1000)
                        .setWaitPeriod(ProviderType.GPS, 10 * 1000)
                        .setWaitPeriod(ProviderType.NETWORK, 5 * 1000)
                        .gpsMessage("Would you mind to turn GPS on?").build())
                .build();

Please advise on how to avoid this issue.

FragmentActivity

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

How disable Google Play and use only wifi and GPS?

I'm making an app for China. But in China, Google Play Services do not work (Great Firewall). Tell me, how can I turn off location determination through Google Play Services and leave only GPS and WiFi?

Thanks!

P.S. Do you planing to add a definition through the GSM of the towers?

Getting location in intervals in Service

I have created service that extends from your LocationBaseService And in getLocationConfiguration I have set this:

@Override
public LocationConfiguration getLocationConfiguration() {
    return new LocationConfiguration.Builder()
            .keepTracking(true)
            .useGooglePlayServices(new GooglePlayServicesConfiguration.Builder().askForSettingsApi(false).build())
            .useDefaultProviders(new DefaultProviderConfiguration.Builder()

                    .requiredTimeInterval(5000).build())
            .build();
}

I haven;t changed onStartCommand and method onLocationChanged is not calling.

Do I need to call getLocation method explicitly every time?

Always get a timeout error message

I always get an error "Couldn't get location, and timeout!" when trying to get the location.
I'm new to Android dev.

@Override public LocationConfiguration getLocationConfiguration() { return new LocationConfiguration() .keepTracking(true) .askForGooglePlayServices(true) .setWaitPeriod(ProviderType.GOOGLE_PLAY_SERVICES, 5 * 1000) .setWaitPeriod(ProviderType.GPS, 10 * 10000) .setGPSMessage("Would you mind to turn GPS on?") .setRationalMessage("Gimme the permission!"); }

09-13 15:58:22.072 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/GPServicesLocationProvider: GoogleApiClient is connected.
09-13 15:58:22.082 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/GPServicesLocationProvider: Ask for location update...
09-13 15:58:22.082 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/GPServicesLocationProvider: Asking for SettingsApi...
09-13 15:58:22.165 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/GPServicesLocationProvider: We got GPS, Wifi and/or Cell network providers enabled enough to receive location as we needed. Requesting location update...
09-13 15:59:11.399 16435-16441/com.lvsandroid.cprojectslvstrainingandroidlocationmanager W/art: Suspending all threads took: 7.510ms
09-13 15:59:11.722 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/LocationManager$2: We couldn't receive location from GooglePlayServices, so switching default providers...
09-13 15:59:11.722 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/GPServicesLocationProvider: Canceling GPServiceLocationProvider...
09-13 15:59:11.728 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/LocationManager: Attempting to get location from default providers...
09-13 15:59:11.745 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/LocationManager: We got permission, getting location...
09-13 15:59:11.772 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/DefaultLocationProvider: GPS is already enabled, getting location...
09-13 15:59:11.777 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/DefaultLocationProvider: LastKnowLocation is not usable.
09-13 15:59:11.777 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/DefaultLocationProvider: Ask for location update...
09-13 16:00:51.793 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/DefaultLocationProvider$4: We waited enough for GPS, switching to Network provider...
09-13 16:00:51.799 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/DefaultLocationProvider: Network is enabled, getting location...
09-13 16:00:51.800 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/DefaultLocationProvider: LastKnowLocation is not usable.
09-13 16:00:51.805 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/DefaultLocationProvider: Ask for location update...
09-13 16:01:11.828 16435-16435/com.lvsandroid.cprojectslvstrainingandroidlocationmanager I/DefaultLocationProvider$4: Network Provider is not provide location in required period, calling fail...
09-13 16:01:11.845 16435-16478/com.lvsandroid.cprojectslvstrainingandroidlocationmanager E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb2ef4880

Support for API 10

Is the API 14 a hard requirement ? Would it be possible, without too much work, to make this library compatible with API 10 ? What features would we lose ?

I'll clone it and dabble with it, but not knowing its codebase at all I felt like I should ask first so as not to run into walls after hours of work, as usual.

This lib looks like the best and most extensive location lib for android ! Congrats !

No class def found with newer version of play services

Problem Description

If I use the library with a newer version of play services(9.6.1), the app crashes becauase of a NoClassDefFoundError (with play-services-location exclude option specified for the LocationManager dependency).

java.lang.NoClassDefFoundError: com.yayandroid.locationmanager.provider.GPServicesLocationProvider at com.yayandroid.locationmanager.LocationManager.locationPermissionGranted(LocationManager.java:278) at com.yayandroid.locationmanager.LocationManager.askForPermission(LocationManager.java:262) at com.yayandroid.locationmanager.LocationManager.get(LocationManager.java:210) at com.yayandroid.locationmanager.LocationManager.get(LocationManager.java:182) at com.yayandroid.locationmanager.LocationBaseActivity.getLocation(LocationBaseActivity.java:28)

Proposed Solution

Update Google Play services dependecy to a newer version.

I've tried to compile the library with play-servives 9.6.1 dependency and then the NoClassDefFoundError does not occur.

java.lang.RuntimeException

20741-20741/com.yayandroid.locationmanager.sample E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                       Process: com.yayandroid.locationmanager.sample, PID: 20741
                                                                                       java.lang.RuntimeException: Unable to resume activity {com.yayandroid.locationmanager.sample/com.yayandroid.locationmanager.sample.activity.SampleActivity}: java.lang.IllegalArgumentException: invalid provider: null
                                                                                           at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4155)
                                                                                           at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4245)
                                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1838)
                                                                                           at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                           at android.os.Looper.loop(Looper.java:158)
                                                                                           at android.app.ActivityThread.main(ActivityThread.java:7224)
                                                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
                                                                                        Caused by: java.lang.IllegalArgumentException: invalid provider: null
                                                                                           at android.location.LocationManager.checkProvider(LocationManager.java:1761)
                                                                                           at android.location.LocationManager.requestLocationUpdates(LocationManager.java:464)
                                                                                           at com.yayandroid.locationmanager.helper.UpdateRequest.run(UpdateRequest.java:39)
                                                                                           at com.yayandroid.locationmanager.providers.locationprovider.DefaultLocationProvider.onResume(DefaultLocationProvider.java:68)
                                                                                           at com.yayandroid.locationmanager.providers.locationprovider.DispatcherLocationProvider.onResume(DispatcherLocationProvider.java:43)
                                                                                           at com.yayandroid.locationmanager.LocationManager.onResume(LocationManager.java:161)
                                                                                           at com.yayandroid.locationmanager.base.LocationBaseActivity.onResume(LocationBaseActivity.java:62)
                                                                                           at com.yayandroid.locationmanager.sample.activity.SampleActivity.onResume(SampleActivity.java:63)
                                                                                           at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1286)
                                                                                           at android.app.Activity.performResume(Activity.java:6987)
                                                                                           at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4144)
                                                                                           at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4245) 
                                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1838) 
                                                                                           at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                           at android.os.Looper.loop(Looper.java:158) 
                                                                                           at android.app.ActivityThread.main(ActivityThread.java:7224) 
                                                                                           at java.lang.reflect.Method.invoke(Native Method) 
                                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

It happens when the Google Api Settings Dialog is dismissed(click cancel button) and default provider starts to work. Pressing for example home button on a device and forcing activity to restart cause this error to occur.

UpdateRequest.class

 public void run() {
        locationManager.requestLocationUpdates(provider, minTime, minDistance, locationListener);
    }

provider in that case is null

using provided to gms service to decrease method count

for some user don't use gms like me, it's a huge cost to including gms dependency in apk. but is it possible to set it as provided ? besides it can solve version problem, everyone can use their targeting gms version and don't need to exclude it again.

SettingsApi doesn't turn on GPS

Hi, at first let me thank you for your great job making this painless and simple library,
The issue I am having with your lib is that when the GPS is off it doesn't turn it on using SettingsApi, It only enables low battery mode or something like that. In the SettingsApi dialog it mentions only WiFi and Cellular data.
Thanks.

make google play services optional (skip if not found on the device)

Hi,

if Google play services is not available on the device, or there is no Internet connexion to update/install it the Location manager fails and can't provide any location from GPS or Network as showed in attached screenshots.

Are there any way to make the use of google play services optional ?

Thanks in advance.

ask_update_google_services
fail_missing_google_services

Hiding popups when user enables gps

There is this case where users see the popup to enable gps and they enable it via quick menu,without clicking on the popup.In that case it would be great for the popups to close automatically .

Thanks for the library!

Exception after giving the permission

Hello when i give the permission to access location i get this exception and the app always crashes

Process: com.panayiotis.locationdemo, PID: 29572
Theme: themes:{}
java.lang.AbstractMethodError: abstract method "com.google.android.gms.common.api.Api$zze com.google.android.gms.common.api.Api$zza.zza(android.content.Context, android.os.Looper, com.google.android.gms.common.internal.zzg, java.lang.Object, com.google.android.gms.common.api.GoogleApiClient$ConnectionCallbacks, com.google.android.gms.common.api.GoogleApiClient$OnConnectionFailedListener)"
at com.google.android.gms.common.api.GoogleApiClient$Builder.zza(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient$Builder.zzuQ(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient$Builder.build(Unknown Source)
at com.yayandroid.locationmanager.provider.GPServicesLocationProvider.get(GPServicesLocationProvider.java:75)
at com.yayandroid.locationmanager.LocationManager.getLocation(LocationManager.java:290)
at com.yayandroid.locationmanager.LocationManager.locationPermissionGranted(LocationManager.java:285)
at com.yayandroid.locationmanager.LocationManager.access$400(LocationManager.java:27)
at com.yayandroid.locationmanager.LocationManager$3.onPermissionsGranted(LocationManager.java:326)
at com.yayandroid.locationmanager.helper.PermissionManager.onRequestPermissionsResult(PermissionManager.java:122)
at com.yayandroid.locationmanager.LocationManager.onRequestPermissionsResult(LocationManager.java:155)
at com.yayandroid.locationmanager.LocationBaseActivity.onRequestPermissionsResult(LocationBaseActivity.java:77)
at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6582)
at android.app.Activity.dispatchActivityResult(Activity.java:6460)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3729)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3776)
at android.app.ActivityThread.-wrap16(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5463)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Samples difficult to understand/follow.

I appreciate you building this library, as there ARE a lot of steps involved to get a users GPS coordinates. However, I'm finding it difficult to follow your code samples.

I'd like to implement a Location Service. What is this SamplePresenter class? Do I need to implement it? I don't understand it's purpose. So to get your library working I need to:

  1. Have a Base Service
  2. Extend it with yet another Location class
  3. Create a Presenter object

I cannot really see where I get my callbacks in your Service-Activity sample.

Stop location updates

Hi,

Once the service is started and getlocation() is called, how do you stop getting location updates? I can stop the service but I'm still getting the location updates, this is in your sample project. I`m using keepTracking(true) and this config.

LocationConfiguration awesomeConfiguration = new LocationConfiguration.Builder()
.keepTracking(true)
.useDefaultProviders(new DefaultProviderConfiguration.Builder()
.requiredTimeInterval(3 * 1000)
.acceptableAccuracy(10.0f)
.setWaitPeriod(ProviderType.GPS, 30 * 1000)
.build())
.build();

thank you in advance.

NullPointerException in DefaultLocationProvider.java:249

com.yayandroid.locationmanager.provider.DefaultLocationProvider$3.onLocationChanged (DefaultLocationProvider.java:249)

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.yayandroid.locationmanager.LocationConfiguration.shouldKeepTracking()' on a null object reference
at com.yayandroid.locationmanager.provider.DefaultLocationProvider$3.onLocationChanged(DefaultLocationProvider.java:249)
at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:285)
at android.location.LocationManager$ListenerTransport.-wrap0(LocationManager.java)
at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:230)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5421)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

at line 249
if (configuration.shouldKeepTracking()) { requestUpdateLocation(configuration.getRequiredTimeInterval(), false); } else { locationManager.removeUpdates(locationChangeListener); }

duplicate entry error after adding firebase dependencies

Hi,

All work fine until I add some firebase dependencies
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zzd.class

even I add to my build file :
`
packagingOptions {

    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}
dexOptions {
    jumboMode true
    javaMaxHeapSize "4g"
}`

Rational Message hiding ?

Hi,

There is some option to hide rational message when requesting permissions?
I want to show only default app dialog to enable/disable permissions.

Best regards,
Pedro Ferreira

java.lang.IllegalStateException: GoogleApiClient is not connected yet.

Configuration

LocationConfiguration.Builder().keepTracking(false)
                .askForPermission(new PermissionConfiguration.Builder().requiredPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION})
                        .rationaleMessage("needs permission to access your location in order to provide a more localized experience.").build())
                .useGooglePlayServices(new GooglePlayServicesConfiguration.Builder()
                        .askForGooglePlayServices(true)
                        .askForSettingsApi(true)
                        .failOnConnectionSuspended(true)
                        .failOnSettingsApiSuspended(false)
                        .ignoreLastKnowLocation(false)
                        .setWaitPeriod(20 * 1000)
                        .build())
                .useDefaultProviders(new DefaultProviderConfiguration.Builder()
                        .acceptableAccuracy(500.0f)
                        .acceptableTimePeriod(5 * 60 * 1000)
                        .gpsMessage("Turn on GPS?")
                        .setWaitPeriod(ProviderType.GPS, 20 * 1000)
                        .setWaitPeriod(ProviderType.NETWORK, 20 * 1000)
                        .build())
                .build();```

### Logs

java.lang.IllegalStateException: GoogleApiClient is not connected yet.
at com.google.android.gms.internal.zzaas.zzb(Unknown Source:5)
at com.google.android.gms.internal.zzaav.zzb(Unknown Source:5)
at com.google.android.gms.internal.zzaat.zzb(Unknown Source:154)
at com.google.android.gms.internal.zzary.removeLocationUpdates(Unknown Source:5)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.removeLocationUpdates(GooglePlayServicesLocationSource.java:96)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationProvider.onLocationChanged(GooglePlayServicesLocationProvider.java:155)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationProvider.checkLastKnowLocation(GooglePlayServicesLocationProvider.java:209)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationProvider.onConnected(GooglePlayServicesLocationProvider.java:114)
at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.onConnected(GooglePlayServicesLocationSource.java:113)
at com.google.android.gms.common.internal.zzm.zzq(Unknown Source:125)
at com.google.android.gms.internal.zzaat.zzo(Unknown Source:22)
at com.google.android.gms.internal.zzaar.zzwi(Unknown Source:89)
at com.google.android.gms.internal.zzaar.onConnected(Unknown Source:21)
at com.google.android.gms.internal.zzaav.onConnected(Unknown Source:7)
at com.google.android.gms.internal.zzaag.onConnected(Unknown Source:5)
at com.google.android.gms.common.internal.zzl$1.onConnected(Unknown Source:2)
at com.google.android.gms.common.internal.zzf$zzj.zzxG(Unknown Source:137)
at com.google.android.gms.common.internal.zzf$zza.zzb(Unknown Source:46)
at com.google.android.gms.common.internal.zzf$zza.zzu(Unknown Source:2)
at com.google.android.gms.common.internal.zzf$zze.zzxH(Unknown Source:57)
at com.google.android.gms.common.internal.zzf$zzd.handleMessage(Unknown Source:149)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.