React-native android ignores navigator.geolocation.getCurrentPosition

I'm trying to use navigator.geolocation.getCurrentPosition on my Android device (Philips Xenium). It works absolutely ok in iphone and genimotion simulator. navigator.geolocation.getCurrentPosition returns absolutely nothing - no errors, no success. However, if I turn off geolocation service in my smartphone, it returns No available location provider.

Also, navigator.geolocation.watchPosition works fine.

Answers


Add the following permission to your AndroidManifest.xml file

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

and then pass an enableHighAccuracy object to your your geolocation.getCurrentPosition method:

navigator.geolocation.getCurrentPosition(
  {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
);

Make sure that Location is enabled in your device.

I enabled <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />, however I kept having the same error until I realized that location was disabled.


Need Your Help

IZPACK custom DataValidator unable to read custom panel user input

izpack

I have created a sample installer using IZPACK API. In this, i have created a custom panel class by extending IzPanel. After that i created a panel data validator by implementing DataValidator inte...

Tangled in generics

java generics inheritance

I have classes A, B with B extends A