Android来电不会以编程方式转发到其他电话号码

时间:2014-09-15 11:33:07

标签: java android android-intent

我正试图在电话接听电话后将来电转接到其他号码。以下是我转发电话的书面代码。它正在进入此onRecieve但呼叫不转发。请帮帮我。

@Override
public void onReceive(final Context context, Intent intent) {

    TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    telephony.listen(new PhoneStateListener(){
        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            super.onCallStateChanged(state, incomingNumber);

            String callForwardString = "**21*9876543210#";    
            Intent intentCallForward = new Intent(Intent.ACTION_DIAL); // ACTION_CALL                               
            Uri uri2 = Uri.fromParts("tel", callForwardString, "#"); 
            intentCallForward.setData(uri2);  
            intentCallForward.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intentCallForward); 
        }

    },PhoneStateListener.LISTEN_CALL_STATE);
}

0 个答案:

没有答案