在android手机记录电话? [英] Record phone calls on android phone?
本文介绍了在android手机记录电话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试过了,使用下面的code记录拨出电话,但它没有。
I tried it and use the following code for recording outgoing calls but it does not..
@Override
public void onReceive(Context context, Intent intent)
{
this.context = context;
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_ANSWER))
{
try
{
phonenbr = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.v("GDHGDHGHDGDHGDHGHDGHDGH", phonenbr);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(pathname);
recorder.prepare();
recorder.start();
recordstarted = 1;
telManager= (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
}
catch(Exception e)
{
e.printStackTrace();
}
final PhoneStateListener phoneListener = new PhoneStateListener()
{
@Override
public void onCallStateChanged(final int state, final String incomingNumber)
{
getTelephonyOverview(telManager);
}
};
telManager.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
}
}
public void getTelephonyOverview(final TelephonyManager telManager)
{
int callState = telManager.getCallState();
switch (callState)
{
case TelephonyManager.CALL_STATE_IDLE:
{
if (recordstarted==1)
{
recorder.stop();
recordstarted =0;
}
break;
}
}
}
请为这个问题的一些很好的解决方案。
Please provide some good solution for this problem..
推荐答案
这可以解决与API级别8+。设置您的音频源媒体记录的电话上行,下行,或两者兼而有之。
This can be solved with API level 8+. Set your audio source for media recorder as phone uplink, downlink, or both.
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL); //Voice downlink/ Uplink
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(AudioEncoder.AAC );
但要注意法律的和在此之前的规定。
But beware of the law and regulations before doing this.
这篇关于在android手机记录电话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文