当我尝试通过此代码转发呼叫时,什么也不会发生。 我想在特定号码上向前拨打电话。请帮助我。
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);
}
实际上应该通过移动设备末尾的#通过#
callforward("**21*MobileNo#");
//传入时。
//对于模拟器,您必须通过**21*5556#
。
这里#对于转发电话更为重要。