问题
I am setting my targetSdkVersion to 23 and therefore I want to implement "Requesting permissions at runtime". (see here)
Lint directly calls out if you forget to check the permission and tells you the following:
Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with
checkPermission
) or explicitly handle a potential `SecurityException'
This is quite nice and I want to analyze my code for any call that I may have forgotten, but I can't find Lint option that I have to select in my Inspection profile.
How is the inspection called? Thanks!
回答1:
First click on Hector the Inspector (the small icon of a man with a moustache at the very bottom-right of Android Studio). This will bring up an option to Configure inspections.
You should then type 'Permissions' into the searchbar, and ensure that "Constant and Resource Type Mismatches" is checked. After that, it's a simple case of running an inspection via Analyse > Inspect Code.
来源:https://stackoverflow.com/questions/34795454/analyze-code-with-lint-for-calls-that-require-permissions