Pau*_*lor 7 android phone-call android-intent
是否可以在Android上检索呼叫转移状态?
使用此代码仅显示具有当前状态的弹出窗口,但我想知道是否可以获取设置的实际数字(如果有)
Intent intentCallForward = new Intent(Intent.ACTION_CALL);
Uri uri = Uri.fromParts("tel", "*#21#", "#");
intentCallForward.setData(uri);
startActivity(intentCallForward);
Run Code Online (Sandbox Code Playgroud)
这很简单。您所需要的只是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);
}
}
}
Run Code Online (Sandbox Code Playgroud)