本文介绍了替换通话应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个非常简单的通话应用程序以替换普通版本.基本上,我只想接听来电,并为用户提供一个非常简单的自定义UI.不需要拨出电话或任何花哨的东西.

I'm trying to develop a really simple in call app to replace the stock version. Basically, I just want to answer incoming calls and present the user with a really simple customized UI. There is no need for outgoing calls or any fancy stuff.

搜索网络时,我发现了包 android.telecom.incallservice (在API 23中可用). 任何希望提供用于管理电话的用户界面的应用都可以实现此服务.

Searching the web I've found package android.telecom.incallservice (available in API 23). This service is implemented by any app that wishes to provide the user-interface for managing phone calls.

这似乎很有希望,但是我很难使其正常工作.我已经创建了扩展InCallService的简单服务,并按照文档中的说明在清单中对其进行了声明.但是,我希望能够将设置中的默认电话应用更改为我自己的,但是我只能找到普通电话应用.

It seems promising but I'm having trouble getting it to work. I've created simple service extending InCallService and declared it in my manifest as described by the docs. However, I would expect to be able to change the default phone app in the settings to my own, but I can only find the stock phone app.

这是来自文档的清单声明.我已经用BIND_INCALL_SERVICE替换了BIND_IN_CALL_SERVICE,因为我猜这是一个错字.

This is the manifest declaration from the docs. I've replaced BIND_IN_CALL_SERVICE with BIND_INCALL_SERVICE since I guess this is a typo.

<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>

问题

  1. 第三方应用程序是否有可能替换呼叫应用程序中的默认值?

  1. Is it even possible for third-party app to replace the default in call app?

是否有使用此API的示例实现,我可以用作参考?我发现了 google实现,但这是一个系统应用程序,它利用了一些其他应用程序无法使用的权限(例如:android.permission.MODIFY_PHONE_STATE).

Are there any sample implementations using this API out there I may use as a reference? I've found the google implementation, but this is a system app which makes use of some permissions that are not available for other apps (ex: android.permission.MODIFY_PHONE_STATE).

我是否假设在提供正确的InCallService清单注册和存根实现后可以在Default Apps -> Phone下找到我的应用?我需要声明其他内容吗?

Am I correct in the assumption that after providing a correct InCallService manifest registration and a stub implementation I could expect to find my app under Default Apps -> Phone? Do I need to declare something else?

谢谢.

推荐答案

根据文档,并在您自己发表评论时,需要将其添加到清单中:

According to the docs and as you comment yourself, you need to add this in your manifest:

<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必须替换为实现此服务的类.

android:name must be replaced by the class that implements this service.

 <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必须替换为实现自己的拨号程序实现的主要活动的类.

android:name must be replaced by the class that implements the main activity for your own dialer implementation.

这是一个示例项目,您可以将其用作指导: https://github.com/arekolek/simple-phone

And here's a sample project that you can use as a guide: https://github.com/arekolek/simple-phone

这是 https://stackoverflow.com/a/49835987/1916449

这篇关于替换通话应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 02:09