ACCESS_FINE_LOCATION not working

Below is my AndroidManifest.xml...

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

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="22" />

<application
  android:name=".BeaconApp"
  android:allowBackup="true"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIzaSyBqhOHH31FYObdzoVW9TmQsv62TOP0LSLI"/>
</application>

As you can see, I added the correct permissions needed to get location information. However, when I run my application, I get a strange error ...

Looks like the app doesn't have permission to access location.
Add the following line to your app AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

throwLocationPermissionMissing
...etc

I already added this to mine AndroidManifest.xml, so why am I getting this error. I tried restarting Android Studio. I tried to clear the data from the emulator. I tried Gradle -> Clean. None of this helped. What's going on here?

Is it possible that my Android emulator is blocking GPS or something like that?

+4
source share
2 answers

.

int permissionCheck = ContextCompat.checkSelfPermission(thisActivity,
    Manifest.permission.ACCESS_FINE_LOCATION);
if(permissionCheck != PackageManager.PERMISSION_GRANTED) {
    // ask permissions here using below code
    ActivityCompat.requestPermissions(thisActivity,
            new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
            REQUEST_CODE);
}

android 6.0

Android 6.0.

, .

+5

, , - . , os 6, .

google "android runtime gps permission", , .

+3

Source: https://habr.com/ru/post/1662747/


All Articles