use*_*139 25 android android-6.0-marshmallow
我正在尝试开发一个非常简单的通话应用程序来替换库存版本.基本上,我只想回答来电并向用户展示一个非常简单的自定义UI.不需要拨出电话或任何花哨的东西.
在网上搜索我找到了包android.telecom.incallservice(在API 23中提供).此服务由希望提供用于管理电话呼叫的用户界面的任何应用程序实现.
这似乎很有希望,但我无法让它工作.我已经创建了扩展InCallService的简单服务,并在文档描述的清单中声明它.但是,我希望能够将设置中的默认手机应用程序更改为我自己的,但我只能找到手机应用程序.
这是文档的清单声明.我已经替换了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>
Run Code Online (Sandbox Code Playgroud)
是否有可能第三方应用程序替换调用应用程序中的默认值?
是否有任何使用此API的示例实现我可以用作参考?我找到了谷歌实现,但这是一个系统应用程序,它利用了一些其他应用程序无法使用的权限(例如:)android.permission.MODIFY_PHONE_STATE.
我是否正确假设在提供正确的InCallService清单注册和存根实现后,我可以期待找到我的应用程序Default Apps -> Phone?我需要申报其他东西吗?
谢谢.
根据文档以及您自己的评论,您需要在清单中添加以下内容:
<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>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
android:name必须替换为实现您自己的拨号器实现的主要活动的类。
您可以在这里找到更多相关信息: https ://developer.android.com/guide/topics/connectivity/telecom/selfManaged
这是一个可以用作指南的示例项目: https ://github.com/arekolek/simple-phone