尝试读取Android棉花糖(Android M)中的联系人时,Android应用程序崩溃 [英] Android app crashes when trying to read contacts in Android Marshmallow (Android M)
问题描述
我已将我的应用定位到SDK版本23(Android Marsmallow)
I have target my app to SDK version 23 (Android Marsmallow)
当我尝试从应用程序中读取联系人时,尽管我在Android清单文件中授予了 READ_CONTACTS 权限,但是却遇到了这个异常.我想简单的尝试捕获将不是正确的处理方法.
When I tried to read a contact from my application I got this exception, though I gave READ_CONTACTS permission in my Android manifest file. I guess the simple try catch wouldn't be the proper handling.
异常详细信息:
由以下原因引起:java.lang.SecurityException:权限被拒绝:从pid = 8373读取com.android.providers.contacts.ContactsProviders2 uri content://com.android.contacts/data,uid=10152需要android.permission.READ_CONTACTS或grantUriPermission()
Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/data from pid=8373, uid=10152 requires android.permission.READ_CONTACTS, or grantUriPermission()
我的清单权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
推荐答案
这是我想要的.
完整的权限相关解决方案.希望它能对某人有所帮助.
Complete permission related solutions. Hope it will help someone.
这篇关于尝试读取Android棉花糖(Android M)中的联系人时,Android应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!