即時通訊錄試圖從錄音機錄製聲音,但在Android 6+我得到權限錯誤。 我添加了詢問權限的代碼(有3個權限詢問)2工作,但是 CAPTURE_AUDIO_OUTPUT顯示錯誤。它只是不要求我批准許可。在日誌中它只是「未授予」 任何人都知道什麼問題?CAPTURE_AUDIO_OUTPUT沒有在運行時詢問權限
public static boolean PermissionCheck(Activity context, String permission, int code) {
boolean state = false;
int permissionCheck = ContextCompat.checkSelfPermission(context,
permission);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(context, new String[]{permission}, code); // define this constant yourself
} else {
// you have the permission
return true;
}
return state;
}
case CAPTURE_AUDIO_OUTPUT_CONSTANT: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Logger.e("CAPTURE PERMISSION GRANTED");
INIT();
} else {
Logger.e("CAPTURE PERMISSION NOT GRANTED");
finish();
}
return;
}
錯誤
W/PackageManager: Not granting permission android.permission.CAPTURE_AUDIO_OUTPUT to package blabla_package (protectionLevel=18 flags=0x3848be46)
清單中
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT"/>
@ Hetfieldan24我有清單 – Peter