一:通话录音状态广播注册
<receiver android:name="com.example.receiver.PhoneReceiver" >
<intent-filter android:priority="1000" >
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<action android:name="android.intent.action.ACTION_NEW_OUTGOING_CALL" />
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
二:通话录音代码
public class PhoneReceiver extends BroadcastReceiver {
public static final String INTENT_PHONE_STR = "phone";
public static final String INTENT_STATE_BOOL = "state";
//手机号
private static String phone;
//是否拨打电话
private static boolean isDial;
@Override
public void onReceive(Context context, Intent intent) {
// 数据为空处理
if (intent == null) {
intent = new Intent();
}
if (Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction())) {// 打出号码
String curPhone = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
phone = curPhone;
isDial = true;
return;
}
// 电话监听
TelephonyManager telMgr = (TelephonyManager) context
.getSystemService(Service.TELEPHONY_SERVICE);
switch (telMgr.getCallState()) {
case Telepho