permission.READ_CONTACTS does not seem to work

前端 未结 6 2067
一向
一向 2021-02-18 17:10

I\'m working on a simple app that browses through the user\'s contacts. Unfortunately I keep getting the following error:

java.lang.SecurityException: Permission         


        
6条回答
  •  心在旅途
    2021-02-18 18:05

    I was totally stuck on this until I read this article about how permissions are handled starting with SDK 23. The critical hint:

    If the application's targetSdkVersion is set to less than 23. It will be assumed that application is not tested with new permission system yet and will switch to the same old behavior: user has to accept every single permission at install time and they will be all granted once installed !

    I opened up my gradle.build file and changed targetSdkVersion 23 to targetSdkVersion 22, and now everything works great! I'll eventually find time to build in the new permissions system and switch back to targetSdkVersion 23, which is probably the more correct answer. This is a temporary shortcut.

提交回复
热议问题