呼叫接收方的声音未录音

时间:2019-01-31 09:15:42

标签: android android-broadcastreceiver android-mediarecorder call-recording

您好,我正在制作通话记录器应用程序。在我的应用程序中,我允许用户记录通话。然后录制将保存在目录中。但是现在我在应用程序中面临一个问题。打电话后,如果我检查保存的录音,只有我的声音可以收听,而呼叫接收方的声音没有录音。谁能帮助我解决这个问题?

public class RecorderService extends Service {

    MediaRecorder recorder;
    static final String TAGS=" Inside Service";

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    public int onStartCommand(Intent intent,int flags,int startId)
    {
        recorder = new MediaRecorder();
        recorder.reset();

        String phoneNumber=intent.getStringExtra("number");
        Log.d(TAGS, "Phone number in service: "+phoneNumber);

        String time=new CommonMethods().getTIme();

        String path=new CommonMethods().getPath();

        String rec=path+"/"+phoneNumber+"_"+time+".mp4";

        recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

        recorder.setOutputFile(rec);

        try {
            recorder.prepare();
        } catch (IOException e) {
            e.printStackTrace();
        }
        recorder.start();

        Log.d(TAGS, "onStartCommand: "+"Recording started");

        return START_NOT_STICKY;
    }

    public void onDestroy()
    {
        super.onDestroy();

        recorder.stop();
        recorder.reset();
        recorder.release();
        recorder=null;

        Log.d(TAGS, "onDestroy: "+"Recording stopped");

    }
}

0 个答案:

没有答案