如何在棉花糖中记录通话

时间:2016-09-20 12:58:31

标签: android android-6.0-marshmallow

我想使用android marshmallow录制通话,因为我使用了以下代码

 myAudioRecorder = new MediaRecorder();
                //myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
                myAudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
                myAudioRecorder.setOutputFile(outputFile);
                myAudioRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);

但是我的logcat

    Request requires android.permission.CAPTURE_AUDIO_OUTPUT
 E/AudioPolicyIntefaceImpl: getInputForAttr() permission denied: capture not allowed

知道如何在棉花糖上录制电话

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:-1)

您需要在运行时请求权限

 ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.CAPTURE_AUDIO_OUTPUT},
                    1);

稍后在

进行处理
@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
 switch (requestCode) {
    case 1: {
     for(int i:grantResults){
       if(i == PackageManager.PERMISSION_GRANTED){
         // do your stuff here.
        }
     }
 }
}