Der Benutzer der von mir entwickelten Anwendung muss den Standort während des Registrierungsprozesses freigeben. Wenn Sie auf die Schaltfläche "Locate me" klicken, erhalten Sie die GPS-Koordinaten (oder was auch immer zur Verfügung steht, weiß ich noch nicht).Android-Sicherheitsausnahme für die Berechtigung, die in der Manifestdatei aufgeführt ist
Wenn die Schaltfläche geklickt wird, erhalte ich diese Fehlermeldung:
java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
Which, von dem, was ich verstehe, mit Auflistung der Erlaubnis in der Manifest-Datei zu tun hat. Aber die Erlaubnis ist da.
Die Threads mit ähnlichen Problemen, die ich gefunden habe vorschlagen, die App von dem Gerät zu deinstallieren, auf dem ich es teste, Reinigung und Wiederaufbau des Projekts. Ich habe das alles gemacht, aber das Problem besteht weiter. Ich muss etwas anderes vermissen, möglicherweise sehr offensichtlich. Irgendwelche Ideen?
Danke!
Das ist mein AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest package = "com.iskillu.iskillu"
xmlns:android = "http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup = "true"
android:icon = "@mipmap/ic_launcher"
android:label = "@string/app_name"
android:supportsRtl = "true"
android:theme = "@style/AppTheme">
<activity
android:name = ".MainActivity"
android:label = "@string/app_name"
android:theme = "@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name = "android.intent.action.MAIN" />
<category android:name = "android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--
ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information.
-->
<meta-data
android:name = "com.google.android.gms.version"
android:value = "@integer/google_play_services_version" />
<activity
android:name = ".JoinActivity"
android:label = "@string/title_activity_join"
android:theme = "@style/AppTheme.NoActionBar">
</activity>
<activity
android:name = ".LoginActivity"
android:label = "@string/title_activity_login"
android:theme = "@style/AppTheme.NoActionBar">
</activity>
<activity android:name = ".RegistrationSuccessfulActivity">
<intent-filter>
<action android:name = "android.intent.action.VIEW" />
<category android:name = "android.intent.category.DEFAULT" />
<category android:name = "android.intent.category.BROWSABLE" />
<data android:scheme = "http" />
<data android:scheme = "https" />
<data android:host = "www.iskillu.com" />
<data android:host = "iskillu.com" />
</intent-filter>
</activity>
<activity android:name = ".presentation.PresentationActivity">
</activity>
</application>
</manifest>
Mit dieser Methode wird die die Ausnahme auslöst, wenn sie ausgeführt:
public void getGpsLocation (View view)
{
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
boolean isProviderEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (! locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
{
Toast.makeText (this.getApplicationContext(), R.string.enable_gps, Toast.LENGTH_LONG).show() ;
}
else
{
try {
Location myLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (myLocation != null)
{
Log.d("TAG", "Not null");
}
else
{
Log.d("TAG", "NULL");
}
}
catch (SecurityException se) {
Log.d("TAG", "SE CAUGHT");
se.printStackTrace();
}
}
}
Mögliches Duplikat von http://stackoverflow.com/questions/32083913/android-gps-requires-access-fine-location-error-event-though-my-manifest-file –
siehe [Link] (http://stackoverflow.com/questions/32083913/android-gps-requires-access-fine-location-error-event-though-my-manifest-file) es hilft dir! hoffe, Sie genießen –
Überprüfen Sie Ihr Ziel api ist es 23? @Dan – Lampard