简体   繁体   English

Android 10 API 29 上的 CallScreeningService getExtras NULL

[英]CallScreeningService getExtras NULL on Android 10 API 29

I am using the Android Class CallScreeningService onScreenCall(Call.Details calldetails) to get all incoming calls and everything works fine!我正在使用 Android 类 CallScreeningService onScreenCall(Call.Details calldetails) 来获取所有来电,一切正常! From now I have an error, that on Android 10 devices the function calldetails.getExras() and calldetails.getIntentExtras() always returns NULL, instead of a Bundle, where I can read some further information.从现在开始,我遇到了一个错误,即在 Android 10 设备上,函数 calldetails.getExras() 和 calldetails.getIntentExtras() 始终返回 NULL,而不是 Bundle,我可以在其中读取更多信息。 On Android 9 devices and older everything works fine.在 Android 9 及更早版本的设备上一切正常。

Someone has a similar issue?有人有类似的问题吗? Here is the Source Code and some Declarations:这是源代码和一些声明:

public class IncomingCallService extends CallScreeningService {

    @Override
    public void onScreenCall(Call.Details callDetails) {
                if (callDetails.getExtras() != null) {
                        Log.d(LOG_TAG, "Everything works on Android 9 or older");
                }else{
                        Log.d(LOG_TAG, "Its Null on Android 10!");
                }  

                if (callDetails.getIntentExtras() != null) {
                        Log.d(LOG_TAG, "Everything works on Android 9 or older");
                }else{
                        Log.d(LOG_TAG, "Its Null on Android 10!");
                }     
}

And Manifest.xml:和 Manifest.xml:

<service android:name=".call_handler.IncomingCallService"
    android:permission="android.permission.BIND_SCREENING_SERVICE">
     <intent-filter>
          <action android:name="android.telecom.CallScreeningService"/>
     </intent-filter>
</service>

According to Android docs:根据 Android 文档:

Note: The Call.Details instance provided to a call screening service will only have the following properties set.注意:提供给呼叫筛选服务的 Call.Details 实例将仅设置以下属性。 The rest of the Call.Details properties will be set to their default value or null.其余的 Call.Details 属性将设置为其默认值或 null。

Call.Details#getCallDirection() Call.Details#getCallDirection()

Call.Details#getConnectTimeMillis() Call.Details#getConnectTimeMillis()

Call.Details#getCreationTimeMillis() Call.Details#getCreationTimeMillis()

Call.Details#getHandle() Call.Details#getHandle()

Call.Details#getHandlePresentation() Call.Details#getHandlePresentation()

Only calls where the Call.Details#getHandle() Uri#getScheme() is PhoneAccount#SCHEME_TEL are passed for call screening.只有 Call.Details#getHandle() Uri#getScheme() 是 PhoneAccount#SCHEME_TEL 的呼叫才会被传递以进行呼叫筛选。 Further, only calls which are not in the user's contacts are passed for screening.此外,只有不在用户联系人中的呼叫才会通过筛选。 For outgoing calls, no post-dial digits are passed.对于去电,不传递拨号后数字。

So what you are seeing it's just the expected behavior for Android 10.因此,您所看到的只是 Android 10 的预期行为。

On Androind 29+ you need user permission :在 Android 29+ 上,您需要用户权限:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
        RoleManager roleManager = (RoleManager) getSystemService(ROLE_SERVICE);
        Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_CALL_SCREENING);
        startActivityForResult(intent, 1);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Android 10 (API 29) 在模拟器上查询 ContentProvider - Query ContentProvider on Emulator with Android 10 (API 29) Android 10 (api 29) 中没有这样的文件或目录 - No such file or directory in Android 10 (api 29) 无法启动 API 29 模拟器(Android 10) - Unable to start API 29 emulator (Android 10) Android 10(api-29)文件写入 - Android 10 (api-29) file writing getIntent()。getExtras()返回null Android - getIntent().getExtras() returns null Android Android getIntent()。getExtras()返回null - Android getIntent().getExtras() returns null CallScreeningService - 几秒钟后断开呼叫 - Android 10 - CallScreeningService - Disconnect call after few seconds - Android 10 Webrtc Android:屏幕共享在 API 29 (Android 10) 上停止工作 - Webrtc Android: Screen Sharing stopped working on API 29 (Android 10) 为什么 android:requestLegacyExternalStorage=“true” 在 Android 10 - API 29 中不起作用 - Why android:requestLegacyExternalStorage=“true” not working in Android 10 - API 29 ListActivity 的 getExtras 是 NULL 在 Android BroadcastReceiver - getExtras from ListActivity are NULL in Android BroadcastReceiver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM