简体   繁体   English

在Android 9.0中没有获得用户拨打的号码即使我在运行时也声明了读取呼叫日志和REad电话状态权限

[英]Not getting user dialed number in Android 9.0 Even i have declared both Read call log and REad Phone State permission at Runtime as well

In my app I am trying to intercept all outgoing calls starting with 00 string. 在我的应用程序中,我试图拦截所有以00字符串开头的传出呼叫。 I used Telephony Manager for the same to get outgoing number and then intercept it. 我使用Telephony Manager来获取传出号码,然后拦截它。 All code was working properly before Android 9.0. 所有代码在Android 9.0之前都正常运行。 But in Android Pie once i made call then my app crashed because i am not getting User Dialed number in Receiver. 但是在Android Pie中,一旦我拨打电话,我的应用就崩溃了,因为我没有在Receiver中获得用户拨打号码。

"Without the READ_CALL_LOG permission, however, the phone number field that's provided in PHONE_STATE_CHANGED broadcasts and through PhoneStateListener is empty." “但是,如果没有READ_CALL_LOG权限,则PHONE_STATE_CHANGED广播和PhoneStateListener中提供的电话号码字段为空。”

So you have to ensure the user grants permission for reading phone number before you try to access any dialed number. 因此,在尝试访问任何拨打的号码之前,您必须确保用户授予读取电话号码的权限。 Also you have to keep a check and a backup plan in case user refuses permission. 此外,您还必须保留支票和备用计划,以防用户拒绝许可。 Your app should handle such case well so as to avoid any null pointers. 您的应用应该很好地处理这种情况,以避免任何空指针。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM