Android sdk23 find places to update and request pe

2020-07-30 04:52发布

问题:

May be I am missing something, but is there a way to quickly know all the places I have to update with the new permission checks needed for Android apps using sdk23?

As a developer this change is very frustrating considering the multiple places that need to be updated. I would like to make sure I don't forget/miss any of them.

I am talking about finding where it will be needed to use these two functions before using the permissions qualified as 'Dangerous'

ContextCompat.checkSelfPermission()
ActivityCompat.requestPermissions()

https://developer.android.com/training/permissions/requesting.html

Dangerous permissions https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous

EDIT

In some cases the code throws SecurityException like when trying to use location without the granted permission. But in other cases it just returns null like here

AccountManager.get(context).getAccountsByType("com.google")

回答1:

Using Android Studio, open the Analyze menu and run Inspect Code... In the results, open Android and then Constant and Resource Type Mismatches. Look for entries that start with "Call requires permission..."