Below is my code, i called this code for getting runtime permission. In this case the "shouldshowrequestpermissionrationale always returns false". I cannot find a solution why it is goind like this. Due to this the run time permission alert not displayed. Suggest me a solution pls...
private void checkRuntimePermission() {
Logger.infoLog("checkRuntimePermission");
if(ActivityCompat.checkSelfPermission(this, permissionsRequired[0]) != PackageManager.PERMISSION_GRANTED){
Logger.infoLog("checkRuntimePermission first if");
if(ActivityCompat.shouldShowRequestPermissionRationale(WelcomeActivity.this,permissionsRequired[0])){
Logger.infoLog("checkRuntimePermission if");
//just request the permission
//Show Information about why you need the permission
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Need Multiple Permissions");
builder.setMessage("This app needs Camera and Location permissions.");
builder.setPositiveButton("Grant", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
ActivityCompat.requestPermissions(WelcomeActivity.this,permissionsRequired,PERMISSION_CALLBACK_CONSTANT);
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}else{
Logger.infoLog("Show request permission rationale false");
}
} else {
//You already have the permission, just go ahead.
Logger.infoLog("Permission given already");
proceedAfterPermission();
}
}