blue-sky blue-sky - 22 days ago 7
Android Question

Unable to access permission(s) within java code from manifest

manifest.java :

/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package com.mfi;

public final class Manifest {
public static final class permission {
public static final String C2D_MESSAGE="permission.C2D_MESSAGE";
}
}


AndroidManifest.xml :




<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BODY_SENSORS"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GPS_PROVIDER" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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




But I'm unable to request any permissions from MainActivity as below code throws compiler error L:
cannot resolve symbol : ACCESS_FINE_LOCATION


ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
1);


How to update manifest.java to generate the permission I'm attempting to access, in this case
Manifest.permission.ACCESS_FINE_LOCATION
?

Answer

Import the below package for Manifest class,

import android.Manifest;

You can easily access the permission Manifest.permission.ACCESS_FINE_LOCATION and others too