<uses-permission>位置不起作用

时间:2015-09-06 10:29:01

标签: android xml gps

我正在尝试使用以下方式访问我的Android设备的地理位置:

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

 manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, listener);

但每次我进入地图屏幕时都会崩溃:

09-06 09:43:32.008    2560-2560/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: dttmultimedia.rsrrevalidatieservice, PID: 2560
java.lang.RuntimeException: Unable to start activity ComponentInfo{dttmultimedia.rsrrevalidatieservice/dttmultimedia.rsrrevalidatieservice.MapActivity}: java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 Caused by: java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
        at android.os.Parcel.readException(Parcel.java:1599)
        at android.os.Parcel.readException(Parcel.java:1552)
        at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:606)
        at android.location.LocationManager.requestLocationUpdates(LocationManager.java:880)
        at android.location.LocationManager.requestLocationUpdates(LocationManager.java:464)
        at dttmultimedia.rsrrevalidatieservice.MapActivity.onCreate(MapActivity.java:50)
        at android.app.Activity.performCreate(Activity.java:6237)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)

<?xml version="1.0" encoding="utf-8"?>

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


<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >


    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
    </activity>

    <activity android:name=".SplashScreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".DetailActivity"
        android:label="Over RSR"
        android:parentActivityName=".MainActivity" >
    </activity>

    <activity
        android:name=".MapActivity"
        android:label="RSR Pechhulp"
        android:parentActivityName=".MainActivity" >

    </activity>

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="@string/google_maps_key" />


</application>

0 个答案:

没有答案