I've been trying to perform a simple permission check on Android.
if (ContextCompat.checkSelfPermission(permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
alertboxGranted();
}
I've been trying support 4x Android (Basically <23 API)
(Also, FYI, I have imported the required components in the Manifest and at the start of the program)
However, when I add the above ContextCompat, it comes up with error that the checkSelfPermission cannot be applied to java.lang.Strings
But isn't ContextCompat basically there to support the checkSelfPermission? I am not sure why it's coming up that error. Can anyone suggest why that error would come up?
Thanks!
However, when I add the above ContextCompat, it comes up with error that the checkSelfPermission cannot be applied to java.lang.Strings
Correct. You are missing the Context
first parameter to the method.
private boolean canGetLocation() {
return(ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)==
PackageManager.PERMISSION_GRANTED);
}