将它们添加到清单文件后的位置权限问题
Location Permission Issues after adding them in manifest file
我是 android 的新手。我试图获取位置详细信息。
在清单文件中,我使用了适当的权限,(Access_Fine_Location).
当我 运行 应用程序时,我仍然收到一条错误消息,指出客户端必须具有访问精确位置权限的权限。
我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="androidfactory.rageshkr.com.iamsafe" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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>
Logcat 日志:
06-21 23:24:50.969 13542-13542/? I/MainActivity﹕ Location Service Connected
06-21 23:24:50.975 13542-13542/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: androidfactory.rageshkr.com.iamsafe, PID: 13542
java.lang.SecurityException: Client must have ACCESS_FINE_LOCATION permission to request PRIORITY_HIGH_ACCURACY locations.
at android.os.Parcel.readException(Parcel.java:1465)
at android.os.Parcel.readException(Parcel.java:1419)
at com.google.android.gms.internal.ni$a$a.a(Unknown Source)
at com.google.android.gms.internal.nj.a(Unknown Source)
at com.google.android.gms.internal.nk.a(Unknown Source)
at com.google.android.gms.internal.nf.a(Unknown Source)
at com.google.android.gms.internal.nf.a(Unknown Source)
at com.google.android.gms.common.api.BaseImplementation$a.b(Unknown Source)
at com.google.android.gms.common.api.c.a(Unknown Source)
at com.google.android.gms.common.api.c.b(Unknown Source)
at com.google.android.gms.internal.nf.requestLocationUpdates(Unknown Source)
at androidfactory.rageshkr.com.iamsafe.MainActivity.onConnected(MainActivity.java:93)
at com.google.android.gms.internal.jm.f(Unknown Source)
at com.google.android.gms.common.api.c.gJ(Unknown Source)
at com.google.android.gms.common.api.c.d(Unknown Source)
at com.google.android.gms.common.api.c.onConnected(Unknown Source)
at com.google.android.gms.internal.jm.f(Unknown Source)
at com.google.android.gms.internal.jm.dU(Unknown Source)
at com.google.android.gms.internal.jl$h.b(Unknown Source)
at com.google.android.gms.internal.jl$h.g(Unknown Source)
at com.google.android.gms.internal.jl$b.hy(Unknown Source)
at com.google.android.gms.internal.jl$a.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
必须在您的 <application>
标签之外。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="androidfactory.rageshkr.com.iamsafe" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这是使用清单文件中的权限、服务、接收器、元数据的示例
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="packagename"
android:installLocation="internalOnly"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.location.GPS_ENABLED_CHANGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<application
android:name="packagename.MyAppilication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Wipro_pos" >
<activity
android:name="packagename.SplashActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="packagename.CaptureSignature"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.findfacts.wipropos.ShopProfileActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="Packagename.CustomProgressBar"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="packagename.LoginActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="packagename.UnsyncRegistrationDetailes"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="packagename.SettingActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="Packagename.VisitActivity"
android:screenOrientation="portrait" >
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<receiver
android:name="Packagename.reciever.NetworkReceiver"
android:label="NetworkReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>
<receiver
android:name="Packagename.reciever.DateChangedReceiver"
android:label="DateChangedReceiver" >
<intent-filter>
<action android:name="android.intent.action.DATE_CHANGED" />
</intent-filter>
</receiver>
<service
android:name="Packagename.UploadOfflineDataService"
android:enabled="true" >
</service>
</application>
我是 android 的新手。我试图获取位置详细信息。 在清单文件中,我使用了适当的权限,(Access_Fine_Location).
当我 运行 应用程序时,我仍然收到一条错误消息,指出客户端必须具有访问精确位置权限的权限。
我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="androidfactory.rageshkr.com.iamsafe" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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>
Logcat 日志:
06-21 23:24:50.969 13542-13542/? I/MainActivity﹕ Location Service Connected
06-21 23:24:50.975 13542-13542/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: androidfactory.rageshkr.com.iamsafe, PID: 13542
java.lang.SecurityException: Client must have ACCESS_FINE_LOCATION permission to request PRIORITY_HIGH_ACCURACY locations.
at android.os.Parcel.readException(Parcel.java:1465)
at android.os.Parcel.readException(Parcel.java:1419)
at com.google.android.gms.internal.ni$a$a.a(Unknown Source)
at com.google.android.gms.internal.nj.a(Unknown Source)
at com.google.android.gms.internal.nk.a(Unknown Source)
at com.google.android.gms.internal.nf.a(Unknown Source)
at com.google.android.gms.internal.nf.a(Unknown Source)
at com.google.android.gms.common.api.BaseImplementation$a.b(Unknown Source)
at com.google.android.gms.common.api.c.a(Unknown Source)
at com.google.android.gms.common.api.c.b(Unknown Source)
at com.google.android.gms.internal.nf.requestLocationUpdates(Unknown Source)
at androidfactory.rageshkr.com.iamsafe.MainActivity.onConnected(MainActivity.java:93)
at com.google.android.gms.internal.jm.f(Unknown Source)
at com.google.android.gms.common.api.c.gJ(Unknown Source)
at com.google.android.gms.common.api.c.d(Unknown Source)
at com.google.android.gms.common.api.c.onConnected(Unknown Source)
at com.google.android.gms.internal.jm.f(Unknown Source)
at com.google.android.gms.internal.jm.dU(Unknown Source)
at com.google.android.gms.internal.jl$h.b(Unknown Source)
at com.google.android.gms.internal.jl$h.g(Unknown Source)
at com.google.android.gms.internal.jl$b.hy(Unknown Source)
at com.google.android.gms.internal.jl$a.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
必须在您的 <application>
标签之外。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="androidfactory.rageshkr.com.iamsafe" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这是使用清单文件中的权限、服务、接收器、元数据的示例
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="packagename"
android:installLocation="internalOnly"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.location.GPS_ENABLED_CHANGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<application
android:name="packagename.MyAppilication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Wipro_pos" >
<activity
android:name="packagename.SplashActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="packagename.CaptureSignature"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.findfacts.wipropos.ShopProfileActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="Packagename.CustomProgressBar"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="packagename.LoginActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="packagename.UnsyncRegistrationDetailes"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="packagename.SettingActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="Packagename.VisitActivity"
android:screenOrientation="portrait" >
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<receiver
android:name="Packagename.reciever.NetworkReceiver"
android:label="NetworkReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>
<receiver
android:name="Packagename.reciever.DateChangedReceiver"
android:label="DateChangedReceiver" >
<intent-filter>
<action android:name="android.intent.action.DATE_CHANGED" />
</intent-filter>
</receiver>
<service
android:name="Packagename.UploadOfflineDataService"
android:enabled="true" >
</service>
</application>