I have follow the tutorial in this link to be able to allow request
permission in runtime
: https://developer.android.com/training/permissions/requesting.html
and it is not working, I copy the same code but with different permission "
ACCESS_FINE_LOCATION"
my code as following
in onCreate method of activity
int permissionCheck = ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_FINE_LOCATION)) {
DialogUtils.showDialogMessage(this, getString(R.string.error),
getString(R.string.error_location_permission_not_granted),
getString(R.string.ok), getString(R.string.cancel), new OnClickListener() {
@Override
public void onClick(View view) {
/*ContextCompat.requestPermissions(ItemDetailsActivity2.this,
new
String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MAP_PERMISSION_REQUEST_CODE);*/
}
}, null);
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MAP_PERMISSION_REQUEST_CODE);
}
}
and this is the call back method
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions,
int[] grantResults) {
switch (requestCode) {
case MAP_PERMISSION_REQUEST_CODE: {
if (grantResults.length > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED) {
initalizeMap();
} else {
DialogUtils.showDialogMessage(this, getString(R.string.error),
getString(R.string.error_location_permission_not_granted),
getString(R.string.ok), null);
}
return;
}
}
}
and this is my build configuration
compileSdkVersion 23
buildToolsVersion '23.0.3'
minSdkVersion 15
targetSdkVersion 15
can anyone please tell me what is going wrong with me ?
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/92a4e7e9-50b0-42fe-879a-8511ebc2428b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.