1

在我的应用程序中,我以这种方式使用自动结束通话来获取号码列表...

public class PhoneStateBroadcastReceiver extends BroadcastReceiver {
private static final String TAG = null;
String incommingNumber;
String inc= "+799999999";

public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();

if(null == bundle)
        return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);       
try {
    // Java reflection to gain access to TelephonyManager's
    // ITelephony getter
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    Log.v(TAG, "Get getTeleService...");
    Class c = Class.forName(tm.getClass().getName());
    Method m = c.getDeclaredMethod("getITelephony");
    m.setAccessible(true);
    com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tm);  
    Bundle b = intent.getExtras();
    incommingNumber = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
    Log.v(TAG,incommingNumber );
    Log.v(TAG,incno1 );
    if ( incommingNumber.equals(inc) )
    {
         telephonyService = (ITelephony) m.invoke(tm);
           telephonyService.silenceRinger();
    telephonyService.endCall();
    Log.v(TAG,"BYE BYE BYE" );
    }
    else{

    telephonyService.answerRingingCall();
    Log.v(TAG,"HELLO HELLO HELLO" );
    }


} catch (Exception e) {
    e.printStackTrace();
    Log.e(TAG,
            "FATAL ERROR: could not connect to telephony subsystem");
    Log.e(TAG, "Exception object: " + e);
}

}
    } 

它适用于我...但未接来电显示在手机中...是否可以隐藏而不显示?

4

1 回答 1

2

是的,使用以下行来取消呼叫通知。 telephonyService.cancelMissedCallsNotification();

于 2013-03-31T08:44:13.513 回答