使用以下代码无法进行电话转接

时间:2019-05-08 07:39:49

标签: android

  

当我尝试通过此代码转接呼叫时,没有任何反应。   我想拨打特定号码的来电。请帮助我。

callforward("**21*MobileNo");// While incoming call.

private void callforward(String callForwardString) {


        PhoneCallListener phoneListener = new PhoneCallListener();
        TelephonyManager telephonyManager = (TelephonyManager)
                ctx.getSystemService(Context.TELEPHONY_SERVICE);
        telephonyManager.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
        Intent intentCallForward = new Intent(Intent.ACTION_CALL);
        Uri mmiCode = Uri.fromParts("tel", callForwardString, ("#"));
        intentCallForward.setData(mmiCode);
        System.out.println("Call FWD Number:"+callForwardString);
        if (ActivityCompat.checkSelfPermission(ctx, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }
        ctx.startActivity(intentCallForward);



    }

1 个答案:

答案 0 :(得分:1)

实际上应该是移动电话号码末尾的通行证#

callforward("**21*MobileNo#"); //来电时。

//对于仿真器,您必须通过**21*5556#

此处#对于转接呼叫更为重要。