是否有新的官方 API 用于拒绝 Android 的来电?
Is there a new, official API for rejecting calls on Android?
背景
很长一段时间以来,都没有官方 API 来阻止对 Android 的调用。
开发人员为 CallerId 和呼叫阻止应用程序所做的是使用一些反射技巧,如图 here。
问题
AndroidP DP3(已在 Pixel 2 上测试)似乎没有阻止应用程序运行。即使是非常流行的应用程序,如 TrueCaller 也无法阻止呼叫。
我相信这是因为它可能会被官方替换 API,因为有些文章讨论了为用户内置的呼叫阻止功能:
https://www.gsmarena.com/android_p_may_introduce_stricter_call_blocking-news-29940.php
我发现了什么
唯一可以替代它的解决方案是扩展 InCallService class,但这样做还必须让您的应用成为默认拨号器应用:
In addition to implementing the InCallService API, you must also
declare an activity in your manifest which handles the
Intent.ACTION_DIAL intent.
不仅如此,一次只能设置一个应用,所以用户不能选择多个来电显示and/or来电拦截应用。
眼看找不到替代品,现在正是求这个东西的最佳时机,我也求了here。
问题
还有其他方法可以拒绝来电吗?
Google现在有提供官方功能吗?
使用新的 Android P API 应该很容易。您的应用需要请求权限 Manifest.permission.ANSWER_PHONE_CALLS
。然后就可以调用TelecomManager
classdoc here.
的方法endCall
背景
很长一段时间以来,都没有官方 API 来阻止对 Android 的调用。
开发人员为 CallerId 和呼叫阻止应用程序所做的是使用一些反射技巧,如图 here。
问题
AndroidP DP3(已在 Pixel 2 上测试)似乎没有阻止应用程序运行。即使是非常流行的应用程序,如 TrueCaller 也无法阻止呼叫。
我相信这是因为它可能会被官方替换 API,因为有些文章讨论了为用户内置的呼叫阻止功能:
https://www.gsmarena.com/android_p_may_introduce_stricter_call_blocking-news-29940.php
我发现了什么
唯一可以替代它的解决方案是扩展 InCallService class,但这样做还必须让您的应用成为默认拨号器应用:
In addition to implementing the InCallService API, you must also declare an activity in your manifest which handles the Intent.ACTION_DIAL intent.
不仅如此,一次只能设置一个应用,所以用户不能选择多个来电显示and/or来电拦截应用。
眼看找不到替代品,现在正是求这个东西的最佳时机,我也求了here。
问题
还有其他方法可以拒绝来电吗?
Google现在有提供官方功能吗?
使用新的 Android P API 应该很容易。您的应用需要请求权限 Manifest.permission.ANSWER_PHONE_CALLS
。然后就可以调用TelecomManager
classdoc here.
endCall