替换 android 9 及以下版本中的 CallRedirectionService

问题描述

我的 Android 清单,

<service android:name=".CallRedirection"
             android:enabled="true"
             android:exported="true"
             android:permission="android.permission.BIND_CALL_REDIRECTION_SERVICE">
        <intent-filter>
            <action android:name="android.telecom.CallRedirectionService"/>
        </intent-filter>
         </service>
<receiver android:name=".CallReceiver">
            <intent-filter>
                <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.PHONE_STATE" />
            </intent-filter>
        </receiver>

呼叫接收器,

//this is not called when user makes outgoing call from built-in phone app(In Android version 9 and below).
public class CallReceiver extends broadcastReceiver {
    private static final String TAG=CallReceiver.class.getSimpleName();
    @Override
    public void onReceive(Context context,Intent intent) {
        log.d(5,TAG,"Entered on Receive");
    }
}

呼叫重定向

@RequiresApi(api = Build.VERSION_CODES.Q)
public class CallRedirection extends CallRedirectionService {

private static final String TAG=CallRedirection.class.getSimpleName();
//this method called when user makes outgoing call from built-in phone app(In Android version 10 ).
    @Override
    public void onPlaceCall(@NonNull Uri handle,@NonNull PhoneAccountHandle initialPhoneAccount,boolean allowInteractiveResponse) {
//In which method I will get user dialled number.
    }
}

我的目标, 我想为 android 9 及以下版本实现 CallRedirectionService。 在 onPlaceCall 方法中,我希望从“句柄”中获取用户拨打的号码。但不幸的是,我对那里的每个方法都为空

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)