尝试将来电(系统管理)添加到 Android 应用程序时如何修复“电话帐户句柄未启用”错误

问题描述 投票:0回答:1

系统管理的连接-放置入站呼叫流程

首先我初始化了电信管理器

private void initializeTelecomManager(){
        Context context=this.getAppContext();
        ComponentName cName = new ComponentName(context, VoiceConnectionService.class);
        String appName=this.getApplicationName(context);
        handle = new PhoneAccountHandle(cName, appName);
        telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
    }

然后注册电话帐户管理员

     this.initializeTelecomManager();
        String appName = this.getApplicationName(this.getAppContext());
        PhoneAccount.Builder builder = new PhoneAccount.Builder(handle, appName)
                .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER);

        PhoneAccount account = builder.build();

        telephonyManager = (TelephonyManager) this.getAppContext().getSystemService(Context.TELEPHONY_SERVICE);

        telecomManager.registerPhoneAccount(account);

但每当我尝试模拟添加来电时,它都会说 -:

Phone Account Handle is not enabled for this user

        Bundle extras = new Bundle();
        Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, "1234567890", null);

        extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, uri);
        extras.putString("EXTRA_CALLER_NAME", callerName);
        extras.putString("EXTRA_CALL_UUID", uuid);

        telecomManager.addNewIncomingCall(handle, extras);
java android flutter kotlin telephonymanager
1个回答
0
投票

对于系统管理的电话帐户,用户必须在电话应用程序设置中明确启用它 https://developer.android.com/reference/android/telecom/TelecomManager#registerPhoneAccount(android.telecom.PhoneAccount)

© www.soinside.com 2019 - 2024. All rights reserved.