java.lang.SecurityException: Provider gps requires ACCESS_FINE_LOCATION permission
会抛出 Location lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
异常
问题是我的清单肯定是正确的。我正在运行Android 4.0.4索尼爱立信xperia arc s。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.appointify.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
答案 0 :(得分:0)
您必须在清单中添加此行。
<uses-permission android:name="android.permisssion.ACCESS_COARSE_LOCATION"></uses-permission>
答案 1 :(得分:0)
重新启动手机就是答案。