我想开发应用程序调用一个非常简单的,以取代现有版本。基本上,我只是想接听来电,并用一个非常简单的定制UI呈现给用户。没有必要拨出电话或任何花哨的东西。
在网上搜索,我发现包android.telecom.incallservice
(在23 API提供)。这项服务是由希望提供用户界面,用于管理电话呼叫任何应用程序来实现。
这似乎很有前途,但我无法得到它的工作。我创建扩展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>
android.permission.MODIFY_PHONE_STATE
)的。InCallService
清单登记存根实现。我希望能找到我的下Default Apps -> Phone
应用程序后?我需要声明别的东西吗?谢谢。
按照docs和你对此有何评论自己,你需要在你的清单中添加此:
<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
必须由实现的主要活动为自己的拨号器实现的类来代替。
在这里,你可以找到更多这方面的信息:https://developer.android.com/guide/topics/connectivity/telecom/selfManaged
而这里的,你可以作为一个指南使用的示例项目:https://github.com/arekolek/simple-phone
- 它甚至有可能为第三方应用,以取代在通话应用程序的默认?
是的,从API 23是可能的。
- 是否有使用此API在那里我可以作为参考使用任何示例实现?我已经找到了google implementation,但是这是一个系统应用程序,它利用一些权限不适用于其他应用程序(例如:
android.permission.MODIFY_PHONE_STATE
)的。
唯一一个我所知道的是,已经在其他答复中提到,以及我创建https://github.com/arekolek/simple-phone样品。
- 我在假设更正提供正确
InCallService
清单登记存根实现。我希望能找到我的下Default Apps -> Phone
应用程序后?我需要声明别的东西吗?
其实,没有。
像another answer on the topic提到的,你不需要InCallService
都出现在名单上。
你需要,虽然,什么是有两个意图过滤器,一用一tel
URI方案,以及一个用空计划注册一个活动(只具有其中之一是不够的):
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.DIAL" />
</intent-filter>
这是vaguely mentioned in the docs和stated explicitly in AOSP code。
这足以显示在此列。只有这样,到provide the UI for the call,你会真正需要的InCallService
。