Java.lang.securityexception: Requires Access_fine_location Or Access_coarse_location Permission
I am developing an android where I want to get user location using NETWORK_PROVIDER,I am not using GPS for this purpose.I am getting following exception java.lang.SecurityException
Solution 1:
The permissions are placed in the manifest tag (not in the application tag) i.e
<?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"package="package.mypackage"android:versionCode="1"android:versionName="1.2"><uses-sdkandroid:minSdkVersion="7" /><applicationandroid:icon="@drawable/icon"android:label="@string/app_name"><activityandroid:name=".MainActivity"android:label="@string/app_name"><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application><uses-permissionandroid:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permissionandroid:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permissionandroid:name="android.permission.INTERNET" /></manifest>
Solution 2:
Please try
<applicationandroid:icon="@drawable/icon"android:label="@string/app_name"><activityandroid:name=".MainActivity"android:label="@string/app_name"><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application><uses-permissionandroid:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permissionandroid:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permissionandroid:name="android.permission.INTERNET" />
Post a Comment for "Java.lang.securityexception: Requires Access_fine_location Or Access_coarse_location Permission"