背景
我正在尝试开发一个非常简单的通话应用程序以替换股票版本。基本上,我只想接听来电,并为用户提供一个非常简单的自定义UI。不需要拨出电话或任何花哨的东西。
在网络上搜索,我找到了 android.telecom.incallservice
包(在API 23中可用)。 该服务由希望提供用于管理电话的用户界面的任何应用程序实现。
看起来很有希望,但是我很难使其正常工作。我已经创建了扩展InCallService的简单服务,并按照文档中的说明在 list 中对其进行了声明。但是,我希望能够将设置中的默认电话应用更改为我自己的电话,但是我只能找到普通电话应用。
代码
这是来自文档的 list 声明。我已经用BIND_IN_CALL_SERVICE
替换了BIND_INCALL_SERVICE
,因为我猜这是一个错字。
<service android:name="your.package.YourInCallServiceImplementation" android:permission="android.permission.BIND_INCALL_SERVICE">
<meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" />
<intent-filter>
<action android:name="android.telecom.InCallService"/>
</intent-filter>
</service>
问题
android.permission.MODIFY_PHONE_STATE
)。 InCallService
list 注册和 stub 实现后,我可以期望在Default Apps -> Phone
下找到我的应用程序吗?我需要声明其他内容吗? 谢谢。
最佳答案
根据docs的描述,您需要在自己的 list 中添加它:
<service android:name="your.package.YourInCallServiceImplementation"
android:permission="android.permission.BIND_INCALL_SERVICE">
<meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" />
<intent-filter>
<action android:name="android.telecom.InCallService"/>
</intent-filter>
</service>
android:name
必须由实现此服务的类替换。 <activity android:name="your.package.YourDialerActivity">
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
android:name
必须替换为为自己的拨号程序实现实现主要 Activity 的类。