Is there a new, official API for rejecting calls on Android?

限于喜欢 提交于 2021-02-17 20:36:14

问题


Background

For a very long time, there wasn't an official API for blocking calls on Android.

What developers did for CallerId and call-blocking apps, is to use some reflection tricks, as shown here.

The problem

It seems no blocking app works on Android P DP3 (tested on Pixel 2). Even very popular apps such as TrueCaller fail to block calls.

I believe this is because it might be replaced with an official API, as there are some articles that talk about built in call blocking capability for users:

https://www.gsmarena.com/android_p_may_introduce_stricter_call_blocking-news-29940.php

What I've found

The only solution that could replace it, is by extending InCallService class, but by doing so you must also have your app become the default dialer app:

In addition to implementing the InCallService API, you must also declare an activity in your manifest which handles the Intent.ACTION_DIAL intent.

Not only that, but only one app can be set as such at a time, so the user can't choose multiple callerId and/or call-blocking apps.

Seeing that I can't find an alternative, and that now it's the best time to request such a thing, I've also requested it here.

The question

Is there another alternative for rejecting calls?

Does Google provide now with an official function to do it?


回答1:


It should be quite easy with the new Android P API. Your app needs to request the permission Manifest.permission.ANSWER_PHONE_CALLS. Then you can call the method endCall of TelecomManager class doc here.



来源:https://stackoverflow.com/questions/51085831/is-there-a-new-official-api-for-rejecting-calls-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!