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

[Android] getCurrentPosition fails with "location unavailable" after GPS has been toggled off and on #1921

Closed
RaederDev opened this issue Sep 3, 2019 · 2 comments

Comments

@RaederDev
Copy link

Steps to reproduce:

  • turn off location services on your device
  • open capacitor app that calls getCurrentPosition()
    -> now it should fail because you turned off location services that's okay so far
  • turn on location services and switch back to your app and run getCurrentPosition() again
    -> now the call STILL FAILS even though location services are turned back on

This is because getBestLocation tries to run getLastKnownLocation on the passive provider which returns null, because no other App has requested a Location since you turned Location services back on. If you switch to google maps and request your current location getCurrentPosition starts working again because the Android location service has another location in memory.

@jcesarmobile
Copy link
Member

Sadly that's how current implementation works, a possible solution is switching to fused location providers, there is already an issue for it, so going to close this one as duplicate-

#379

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 14, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants