Android-电话录音

Android-电话录音

TelephonyManager telManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);

//通过电话管理监听通话状态(回调机制)

telManager.listen(listener,PhoneStateListener.LISTEN_CALL_STATE);

listener = new PhoneStateListener(){

         public void onCallStateChanged(int state,String incomingNumber){

                   Switch(state){

                            Case TelephonyManager.CALL_STATE_IDLE://空闲

                            CASE TelephonyManager.CALL_STATE_OFFHOOK:挂起电话

                            CASE TelepnhonyManager.CALL_STATE_RINGING:振铃

}

}

}

//录音

Recorder = new MediaRecorder();

recorder.setAudioSource(MediaRecorder.OutputFormat.THREE_GPP);//.3gp

recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

recorder.setOutputFile(“/mnt/sdcard/”+filename);

recorder.prepare();

recorder.start();

recoding = true;

<uses-permission android:name=”android.permission.READ_PHONE_STATE”/>

android2.0(API 5)测试通过,2.2不可以.

 

通过Receiver机制(收到手机启动完成的广播)启动电话录音服务

XxxReceiver extends Receiver{

         Public void onReceive(){

                   Intent = new Intent(this,XxxxService.class);

                   startService(intent);

}

}

//配置使用权限

<uses-permission  www.2cto.com

android:name = “android.permission.RECEIVE_BOOT_COMPLETED”/>

<uses-permission android:name=”android.permission.READ_PHONE_STATE”/>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<uses-permission android:name=”android.permission.INTERNET”/>

<uses-permission android:name=”android.permission.RECORD_AUDIO”/>

注:

         电话录音者应用程序需要停止卡塔莎录屏软件,否则电脑卡死。


作者:toto1297488504

你可能感兴趣的:(Android-电话录音)