如何阻止外出通话?

时间:2012-03-29 06:34:09

标签: android android-emulator

我使用以下代码阻止了来电,

{
     telephonyService = (ITelephony) method.invoke(telephonyManager);
     telephonyService.silenceRinger();
     telephonyService.endCall();
} 

但我想知道如何阻止外出电话?

1 个答案:

答案 0 :(得分:3)

<receiver android:name="MyPhoneReceiver">
            <intent-filter android:priority="100">
                <action android:name="android.intent.action.PHONE_STATE"></action>
                <action android:name="android.intent.action.NEW_OUTGOING_CALL"></action>
            </intent-filter>
        </receiver>

并在你的广播接收器中

@Override
    public void onReceive(Context context, Intent intent) {
      TelephonyManager telephony = (TelephonyManager)  context.getSystemService(Context.TELEPHONY_SERVICE);
CustomPhoneStateListener customPhoneListener = new CustomPhoneStateListener (context);
telephony.listen(customPhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
}

用这个你可以得到号码

看到这个阻止来电How to Block outgoing calls and Text SMS检查dharmendra回答

相关问题