你可以告诉我,我是Android的新手:)并努力检索联系人列表。我确实在AndroidManifest.xml中添加了android.permission.READ_CONTACTS,但它仍无效。我在Windows 10上运行它,如果这有任何区别。提前谢谢。
09-07 17:27:15.819 5272-5272/? I/art﹕ Not late-enabling -Xcheck:jni (already on)
09-07 17:27:15.819 5272-5272/? I/art﹕ Late-enabling JIT
09-07 17:27:15.821 5272-5272/? I/art﹕ JIT created with code_cache_capacity=2MB compile_threshold=1000
09-07 17:27:15.871 5272-5272/com.sr.phonecontactslist W/System﹕ ClassLoader referenced unknown path: /data/app/com.sr.phonecontactslist-1/lib/x86
09-07 17:27:15.879 5272-5272/com.sr.phonecontactslist D/AndroidRuntime﹕ Shutting down VM
09-07 17:27:15.879 5272-5272/com.sr.phonecontactslist E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.sr.phonecontactslist, PID: 5272
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sr.phonecontactslist/com.sr.phonecontactslist.MainActivity}: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{15540fd 5272:com.sr.phonecontactslist/u0a59} (pid=5272, uid=10059) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{15540fd 5272:com.sr.phonecontactslist/u0a59} (pid=5272, uid=10059) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
at android.os.Parcel.readException(Parcel.java:1599)
at android.os.Parcel.readException(Parcel.java:1552)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:3550)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:4778)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2018)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1468)
at android.content.ContentResolver.query(ContentResolver.java:475)
at android.content.ContentResolver.query(ContentResolver.java:434)
at com.sr.phonecontactslist.MainActivity.onCreate(MainActivity.java:20)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)