I\'m trying to check if the user has android.Manifest.permission.ACCESS_FINE_LOCATION enabled. When running the application, I get a NullPointerException error.
pack
if (ActivityCompat.checkSelfPermission((Activity)mContext, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity)mContext, new String[]{
android.Manifest.permission.ACCESS_FINE_LOCATION
}, 10);
}
Try to use (Activity)mContext instead of this. it may help.
if (ActivityCompat.checkSelfPermission(ActivityName.this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(ActivityName.this, new String[]{
android.Manifest.permission.ACCESS_FINE_LOCATION
}, 10);
}
Try with your ActivityName.this