android 监听去电接通

    Android如何监听去电接通,是去电,不是来电。

    去电接通和来电接通都是接通吧,应该都是一样的state,TelephonyManager.CALL_STATE_OFFHOOK

    要在AndroidManifest.xml注册广播接收器:
    <receiver android:name=”.PhoneReceiver”>
    <intent-filter>
    <action android:name=”android.intent.action.PHONE_STATE”/>
    <action android:name=”android.intent.action.NEW_OUTGOING_CALL” />
    </intent-filter>
    </receiver>
    <receiver android:name=”.PhoneReceiver”> <intent-filter> <action android:name=”android.intent.action.PHONE_STATE”/> <action android:name=”android.intent.action.NEW_OUTGOING_CALL” /> </intent-filter> </receiver>
    还要添加权限:
    <uses-permission android:name=”android.permission.READ_PHONE_STATE”></uses-permission>
    <uses-permission android:name=”android.permission.PROCESS_OUTGOING_CALLS”></uses-permission>

    Similar Category Post

    发表评论

    电子邮件地址不会被公开。 必填项已用*标注