When adding permissions to my manifest file, the below xml works.
Try this:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_SELECT_PICTURE);
return;
}
When you type "Manifest", Android Studio should suggest you to choose a few options of Manifest. You should choose the one start android instead of the name of your project.
If you access the reference of Manifest.java and you can find there is only 1-2 lines in "Permission" class, then you are referencing the wrong manifest class.
I had a similar problem where used;
ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED
where it could not resolve symbol READ_CONTACTS
.
However on using;
import android.Manifest;
It started to recognize READ_CONTACT
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}
change it to
android.manifest.permission.ACCESS_FINE_LOCATION
Try this before running, make sure you have permission to access..
try {
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
} catch (SecurityException e) {
dialogGPS(this.getContext()); // lets the user know there is a problem with the gps
}
Change
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}
To this
new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}
Your problem will be resolved.