Android 电信系统角色管理器

如何解决Android 电信系统角色管理器

我正在尝试实现调用应用程序。对于 API = 29,我无法获得显示提示,也无法将我的应用程序设置为设置下的认拨号程序。它没有显示一个选项。但是它使用 API

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ceptor">

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
    <uses-permission android:name="android.permission.READ_CALL_LOG" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Ceptor">

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <action android:name="android.intent.action.CALL" />
                <action android:name="android.intent.action.CALL_BUTTON" />
                <action android:name="android.intent.action.ANSWER" />
                <action android:name="android.intent.category.DEFAULT" />
                <action android:name="android.intent.category.broWSABLE" />
                <action android:name="android.intent.action.VIEW" />
                <!-- The directives below this comment seem to be sufficient for API < 29 -->
                <action android:name="android.intent.action.DIAL" />
                <data android:scheme="tel" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.DIAL" />
                <!-- The directives above this comment seem to be sufficient for API < 29 -->
                <action android:name="android.intent.category.DEFAULT" />
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.CALL" />
                <action android:name="android.intent.action.CALL_BUTTON" />
                <action android:name="android.intent.action.ANSWER" />
            </intent-filter>

        </activity>

        <receiver android:name=".CeptorBootCompleteReceiver" android:directBootAware="true" >
            <intent-filter>
                <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            </intent-filter>
        </receiver>

        <service android:name=".CeptorConnectionService"
            android:label="The_label_for_my_connection_service"
            android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
            <intent-filter>
                <action android:name="android.telecom.ConnectionService" />

            </intent-filter>
        </service>


    </application>

</manifest>

对于 API

这里是我在 TelecomManager 注册我的东西的地方。

        // change from com.google.android.dialer

        if (Build.VERSION.SDK_INT >= 29)
        {
            RoleManager rm = (RoleManager) getSystemService(Context.ROLE_SERVICE);
            Intent intent = rm.createRequestRoleIntent(RoleManager.ROLE_DIALER);
            startActivityForResult(intent,1);
        }
        else
        {
            Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
            intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME,this.getPackageName());
            startActivity(intent);
        }


        TelecomManager tm = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);

        // Create a new PhoneAccountHandle with the name "CeptorHandle" which uses my CeptorConnectionService.
        ComponentName cn = new ComponentName("com.example.ceptor","com.example.ceptor.CeptorConnectionService");
        PhoneAccountHandle pah = new PhoneAccountHandle(cn,"CeptorHandle");

        
        // Create a new phone account which is associated with the PhoneAccountHandle "CeptorHandle".
        final int capabilities =    PhoneAccount.CAPABILITY_CALL_PROVIDER |
                                    PhoneAccount.CAPABILITY_CONNECTION_MANAGER;

        PhoneAccount pa = PhoneAccount.builder(pah,"CeptorHandle").setCapabilities(capabilities).build();

    }

所以我们在这里看到我将 ROLE_SERVICE 和 ROLE_DIALER 用于我的 RoleManager。 但是,我从来没有得到提示。从这里阅读它:

https://proandroiddev.com/android-q-to-the-res-q-9a88733aedda

我看到它说:

为了让 RoleManager 正确解析请求,您的清单必须指定类别、权限或其他意图过滤器,以便正确持有角色。如果您不这样做,请求将被自动取消

但即使在官方 Android 文档中,我也没有看到角色 ROLE_DIALER 的特定类别、权限或其他意图过滤器的确切列表。

https://developer.android.com/reference/androidx/core/role/RoleManagerCompat#ROLE_DIALER

我认为 API 之间的区别在于较旧的 API 使用 TelecomManager 的 Intent,而较新的 API 使用这个新的 RoleManager。我想就是这样,但也许我离题了。

总之……为什么这对 API

解决方法

<action android:name="android.intent.category.DEFAULT" />

应该是

<category android:name="android.intent.category.DEFAULT" />

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?