Android没有显示RECORD_AUDIO的权限对话框
我在android manifest
中添加了所需的权限<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
以及以下代码
private boolean checkPermission() {
int result = ContextCompat.checkSelfPermission(this, android.Manifest.permission.RECORD_AUDIO);
if (result == PackageManager.PERMISSION_GRANTED) {
return true;
} else {
return false;
}
}
private void requestPermission() {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, android.Manifest.permission.RECORD_AUDIO)) {
Toast.makeText(this, "RECORD AUDIO Permission is required.",
Toast.LENGTH_LONG).show();
} else {
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.RECORD_AUDIO},
PERMISSION_REQUEST_CODE);
}
}
并检查
if (!checkPermission()) {
requestPermission();
}
但是没有显示询问权限的对话框或要求许可的屏幕,
我在模拟器上测试android 6.0