ACCESS_FINE_LOCATION Berechtigung
Ich bin litte schämen. Kann aber nicht finden was falsch ist.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.szymon.gpslab1"
android:versionCode="15"
android:versionName="4.0.3">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<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>
</application>
</manifest>
Es ist mein manifest.
und hier ist mein code:
public class MainActivity extends AppCompatActivity {
LocationManager locationManager;
LocationListener locationListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationListener = new MyLocationListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
}
private class MyLocationListener implements LocationListener{
@Override
public void onLocationChanged(Location location) {
System.out.println("ZMIENIAMY SIĘ, zmieniamy siebie");
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
}
}
Im mit der neuesten android-studio (intellij) mit eingebetteten (?) emulator. Telefon außerhalb der Optionen.
Und hier was ich habe:
FATAL EXCEPTION: main
Process: com.example.szymon.gpslab1, PID: 3274
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.szymon.gpslab1/com.example.szymon.gpslab1.MainActivity}: java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
Caused by: java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
Ich glaub das ist blöder Fehler, aber ich habe nie wie für android entwickelt, die im javaman, und ich habe erreicht jeder tutorial-on-net, kann nicht finden Antwort.
Ah und y, ich habe die Lage in meinem emulator.
Welche Android-version Sie testen auf, und was ist Ihre
Ich glaub die Standard-Einstellung. So minimal 15, max (target?) 23? Aber nicht sicher. Versucht, die änderung im androidmanifest mit <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15"/> nicht helfen noch. Blick auf AndroidEnthausiast Antwort jetzt.
commonsware.com/blog/2015/08/31/...
targetSdkVersion
?Ich glaub die Standard-Einstellung. So minimal 15, max (target?) 23? Aber nicht sicher. Versucht, die änderung im androidmanifest mit <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15"/> nicht helfen noch. Blick auf AndroidEnthausiast Antwort jetzt.
commonsware.com/blog/2015/08/31/...
InformationsquelleAutor Sarseth | 2015-10-04
Schreibe einen Kommentar Antworten abbrechen
Du musst angemeldet sein, um einen Kommentar abzugeben.
Dies ist eine häufige Ausnahme, wenn Sie Ihre Ziel-SDK-23 in Ihrem Aufbau.gradle.
Android 6.0 /sdk 23 stellt eine neue Art des ersuchenden Berechtigungen.
Siehe den link unten für den Umgang mit Berechtigungen:
https://developer.android.com/training/permissions/index.html
InformationsquelleAutor AndroidEnthusiast