7

是否可以在 Android 上检索呼叫转移状态?

在此处输入图像描述

使用此代码仅显示当前状态的弹出窗口,但我想知道是否可以获取设置的实际数字(如果有)

Intent intentCallForward = new Intent(Intent.ACTION_CALL);                               
Uri uri = Uri.fromParts("tel", "*#21#", "#"); 
intentCallForward.setData(uri);                                
startActivity(intentCallForward);
4

1 回答 1

1

这很简单。您所需要的BroadCast只是跟踪您的手机状态。尝试这样的事情:

public class CallBroadcastReceiver extends BroadcastReceiver
{
    public static String numberToCall;
    public void onReceive(Context context, Intent intent) {
        Log.d("CallForwardingBroadCast", "CallBroadcastReceiver::onReceive got Intent: " + intent.toString());
        if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
            numberToCall = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
            Log.d("CallRecorder", "CallBroadcastReceiver intent has EXTRA_PHONE_NUMBER: " + numberToCall);
        }
    }
}
于 2015-10-26T09:47:59.977 回答