Analyze code with Lint for calls that require permissions

你离开我真会死。 提交于 2020-01-12 08:27:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!