从PHONE_STATE intent action android 9读取数字 [英] Read numbers from the PHONE_STATE intent action android 9 Not working

查看:163
本文介绍了从PHONE_STATE intent action android 9读取数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过onrecieve()方法从意图额外的电话中检索清单文件中注册的以下广播接收者的电话号码.

I was trying to retrieve the phone number from intent extra through onrecieve() method for the following broadcast receiver registered in manifest file.

  <intent-filter>
            <action android:name="android.intent.action.PHONE_STATE" />
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        </intent-filter>

我可以成功读取除在我的Pixel 2设备中升级的android pie以外的所有版本的电话号码.根据文档,该应用需要其他阅读权限具有READ_CALL_LOG权限和READ_PHONE_STATE权限的电话号码,但是即使允许了这些权限,我仍然缺少READ_CALL_LOG的权限,因此我无法读取电话号码.请帮助我解决此问题.

I can successfully able to read the phone number for all the version except android pie upgraded in my pixel 2 device. According to the documentation, app requires additional permission for reading phone number which are READ_CALL_LOG permission and the READ_PHONE_STATE permission but even after allowing these permission I still get missing permission for READ_CALL_LOG therefore I couldn't able to read the phone number. Please help me in resolving this issue.

推荐答案

确保在Android 6.0+中的运行时授予READ_PHONE_STATE和READ_CALL_LOG权限:
https://developer.android.com/distribute/best-practices/develop/runtime-permissions

Make sure you grant READ_PHONE_STATE and READ_CALL_LOG permissions at runtime in Android 6.0+:
https://developer.android.com/distribute/best-practices/develop/runtime-permissions

此外,请注意,授予这两个权限后,您将收到ACTION_PHONE_STATE_CHANGED次广播意图操作;一个用电话号码填充EXTRA_INCOMING_NUMBER,另一个用空白填充.

您可以在这里找到更多信息:
https://developer.android.com/reference/android/telephony/TelephonyManager .html#ACTION_PHONE_STATE_CHANGED

Also, note that after granting these two permissions, you will receive ACTION_PHONE_STATE_CHANGED broadcast intent action twice; one with the EXTRA_INCOMING_NUMBER populated with the phone number, and another with it blank.

You can find more information here:
https://developer.android.com/reference/android/telephony/TelephonyManager.html#ACTION_PHONE_STATE_CHANGED

这篇关于从PHONE_STATE intent action android 9读取数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆