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 in Android 8.0.0 Oreo #34

Open
NarendraSingh88 opened this issue Sep 27, 2018 · 4 comments
Open

Not getting location in Android 8.0.0 Oreo #34

NarendraSingh88 opened this issue Sep 27, 2018 · 4 comments

Comments

@NarendraSingh88
Copy link

NarendraSingh88 commented Sep 27, 2018

Below is the code that I tried for retrieving current location.

          FusedLocation.setLocationInterval(20000);
          FusedLocation.setFastestLocationInterval(15000);
          FusedLocation.setSmallestDisplacement(10);

          FusedLocation.setLocationPriority(
            FusedLocation.Constants.HIGH_ACCURACY
          );
          FusedLocation.startLocationUpdates();
    
          
          FusedLocation.getFusedLocation().then(location => {

           

            if (location != null) {
              let initialPosition = JSON.stringify(location);
              this.state.latitude = location.latitude;
              this.state.longitude = location.longitude;
              this.state.timestamp = location.timestamp;
              this.state.initialPosition = initialPosition;

              
            } else {
              alert("Location unavailable, please try later");
            }
          }).catch(error => {  // fused location catch
             console.log("location retrieval failed");
          });

I have tried it in a few of the devices including Oreo (both 8.0.0 and 8.1.0), along with the devices having the lower versions, like Marshmallow and Nougat.

What I have observed is that - in the devices having versions 8.0.0 (including ONEPLUS A3003, and Nokia), this code is not working as expected, and its not even getting inside

FusedLocation.getFusedLocation().then(location => {

nor inside the catch block.

Though, I am getting E/request: 100 in log.

In other devices (4-5 devices), in which I have tested, including MI A1 Oreo 8.1.0, and the devices with versions lower than Oreo, it seems working fine.

I am unable to figure out whats wrong with 8.0.0, or is there anything wrong in my code, due to which its not specifically working in Android Oreo 8.0.0.

@MustansirZia
Copy link
Owner

Hi @NarendraSingh88!
First of all, don't call startLocationUpdates. That's used in the case you want continuous location updates based on your LocationRequest. getFusedLocation should be enough for you at this moment.
Secondly, I don't think you need to check the location != null scenario as if the promise resolves, the Location will never be null.

@NarendraSingh88
Copy link
Author

NarendraSingh88 commented Sep 28, 2018

@MustansirZia But, my problem is still the same, i.e, the fused location Promise isn't getting resolved, and its not even getting inside
FusedLocation.getFusedLocation().then(location => {
in the specific version - 8.0.0 (my observation). My main goal is to achieve that specifically.
In other versions, the same code is working fine.

@NULL-SWEAT
Copy link

I'm also having this issue on my Moto X4(8.0.0).
On an emulator running api 26, which is android 8.0, it works flawlessly.
The thing is, a lot of people are having trouble with their location on the device I mentioned, and even on Google Maps it's not working. It was working fine when it was running 7.1.1.

@MustansirZia
Copy link
Owner

@NarendraSingh88, @NULL-SWEAT. This looks a little strange as the locations on 8.1.0 are working fine. I will take a look into this. Maybe an API depreciation or something else.

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

No branches or pull requests

3 participants