Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting location when asking a new one #12

Closed
facundomedica opened this issue Sep 22, 2016 · 1 comment
Closed

Not getting location when asking a new one #12

facundomedica opened this issue Sep 22, 2016 · 1 comment
Labels

Comments

@facundomedica
Copy link

facundomedica commented Sep 22, 2016

If I use this constructor:

public SimpleLocation(final Context context, final boolean requireFine, final boolean passive, final long interval, final boolean requireNewLocation) {...}

Passing true to requireNewLocation I can't get a location and onLocationChanged is never called.

But using works perfectly:

public SimpleLocation(final Context context, final boolean requireFine, final boolean passive, final long interval) {
    this(context, requireFine, passive, interval, false);
}

EDIT:
Well, not that perfectly in a Samsung Galaxy S4 mini

EDIT 2:
I realized that it's reaching the catch inside this function, but I can't check the error (Maybe I'll have to run the source):

    private Location getCachedPosition() {
        if (mCachedPosition != null) {
            return mCachedPosition;
        }
        else {
            try {
                return mLocationManager.getLastKnownLocation(getProviderName());
            }
            catch (Exception e) {
                return null;
            }
        }
    }

Maybe a bug?
Thanks!

@ocram ocram added the question label Oct 4, 2016
@ocram
Copy link
Contributor

ocram commented Oct 4, 2016

Passing true to requireNewLocation I can't get a location and onLocationChanged is never called.

Setting requireNewLocation to true prevents you from being able to use any cached locations. Thus a new location must indeed be detected for this configuration. This may take some time. But no matter how many seconds it takes, there really should be some result.

Are you sure you've set up your callback correctly and logged something in the onLocationChanged method of that callback?

What about your device configuration? Is network location or GPS location set up correctly? Does it work with other apps?

public SimpleLocation(final Context context, final boolean requireFine, final boolean passive, final long interval) {
    this(context, requireFine, passive, interval, false);
}

Can you show how you call that method instead of how it's defined by this library? That would be more helpful (in this and the previous case). Thanks!

I realized that it's reaching the catch inside this function, but I can't check the error (Maybe I'll have to run the source)

That's definitely some helpful information. Thank you!

  • Are you sure you've added the correct permissions to your app? To exclude this possible issue during development, consider adding both permissions (see README).
  • It really depends on the way you call that constructor. Make sure not to enable passive mode while using a network/coarse location. Passive mode is only available for GPS/fine location.
  • You can checkout the code from this project and run the included sample application from Android Studio. This way, you can test all configurations that you're interested in while being able to change the library's code (in the included module) and adding log statements. Unfortunately, we can't debug that piece for you because we don't have the issues that you have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants