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

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);
}

}
    }


它对我有用...但是未接来电显示在电话中...可以隐藏它而不显示吗?

最佳答案

是的,请使用以下行取消通话通知。
 telephonyService.cancelMissedCallsNotification();

关于android - 在telephonyService.endCall()之后隐藏已通过的调用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11757628/

10-09 09:31