通话录音申请中的问题 [英] Issue in call recording application
本文介绍了通话录音申请中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm working on Call Recording Android Application & facing issue in application, when i'm recording call only speaker voice is recording but Incomming voice is not recording, i already changed all setting of audio format but facing same issue,
If anyone worked on call recording android application , kindly help me.
Thanks...!
我的尝试:
What I have tried:
Here is code.
public class RecordingService extends Service {
private MediaRecorder rec;
private boolean recoderstarted;
private File file;
String path = "sdcard/alarms/";
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
//return super.onStartCommand(intent, flags, startId);
file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
Date date = new Date();
String stringDate = DateFormat.getDateTimeInstance().format(date);
rec = new MediaRecorder();
rec.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
rec.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
rec.setOutputFile(file.getAbsoluteFile() + "/" + stringDate + "callrec.3gp");
rec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
TelephonyManager manager = (TelephonyManager) getApplicationContext().getSystemService(getApplicationContext().TELEPHONY_SERVICE);
manager.listen(new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
if (TelephonyManager.CALL_STATE_IDLE == state ){
try {
if (rec == null) {
rec.stop();
rec.reset();
rec.release();
recoderstarted = false;
rec = null;
stopSelf();
Toast.makeText(getApplicationContext(),"Recording Stop.",Toast.LENGTH_SHORT).show();
} else {
rec.stop();
rec.reset();
rec.release();
recoderstarted = false;
rec = null;
stopSelf();
Toast.makeText(getApplicationContext(),"Recording Stop.",Toast.LENGTH_SHORT).show();
}
}
catch(Exception e) {
e.printStackTrace();
}
}
else if(TelephonyManager.CALL_STATE_OFFHOOK==state){
try {
file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
Date date = new Date();
String stringDate = DateFormat.getDateTimeInstance().format(date);
rec = new MediaRecorder();
rec.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
rec.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
rec.setOutputFile(file.getAbsoluteFile() + "/" + stringDate + "callrec.3gp");
rec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
TelephonyManager manager = (TelephonyManager) getApplicationContext().getSystemService(getApplicationContext().TELEPHONY_SERVICE);
rec.prepare();
rec.start();
recoderstarted=true;
Toast.makeText(getApplicationContext(),"Recording Start.",Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}, PhoneStateListener.LISTEN_CALL_STATE);
return START_STICKY;
}
}
推荐答案
您是否尝试过增加音量
Have you tried increasing the volume
audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL), 0);
这篇关于通话录音申请中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文