棉花糖权限对话框ALLOW按钮不工作为什么



我根据新材料设计集成了棉花糖权限对话框,但权限对话框在模拟器上工作,但在实际设备上不工作。而且我没有犯任何错误。有谁能帮我吗?

我正在使用以下代码:-

ActivityCompat.requestPermissions(这个,new String[]{Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.license.ACCESS_FINE_LOCATION},MY_PERMISSIONS_REQUEST_LOCATION);

这不是代码的问题。。。。

我也遇到了同样的问题,并在类似的stackoverflow帖子的帮助下解决了这个问题。

解决方案

强制停止此应用程序将使权限对话框允许按钮再次工作。

我这样做可能对u 有用

if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CALL_PHONE) && ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_PHONE_STATE)) {
showDialogOK("Phone State & Call Phone Services Permission required for this app",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
checkAndRequestPermissions();
break;
case DialogInterface.BUTTON_NEGATIVE:
// proceed with logic by disabling the related features or quit the app.
finish();
break;
}
}
});
}

showDialog方法及其在CALL_PHONE和READ_PHONE_STATE 中的应用

private void showDialogOK(String message, DialogInterface.OnClickListener okListener) {
new AlertDialog.Builder(this)
.setMessage(message)
.setPositiveButton("OK", okListener)
.setNegativeButton("Cancel", okListener)
.create()
.show();
}

最新更新