Android Tutorial How to determine needed permissions from JavaObject code

Now and then there are JavaObject code snippets posted in the forum. Usually there are permissions required listed together with the code, but not always. Which could be because none are needed. (This very small tutorial sprung out of this thread.)


This is how one determines what permissions are required by a section of JavaObject code.

  1. Look for RunMethods in the JavaObject code. (Because permissions are required on method level.)

  2. Go to the Android reference docs at https://developer.android.com/reference

  3. In search box, enter each method and go to it in the docs (can be a lot simpler to get there by picking it from the dropdown list, if it's listed)

  4. If the method require permissions, they will be listed. If the method don't require permissions, nothing will be shown.

That's it, really.

Example:

Using the code for Draw on top of other apps permission, we find the RunMethod canDrawOverlays. So we search for that in the documentation, get amazed on how difficult it is to find amongst the crappy search results produced by Google, until we finally find a page that contains the info we're looking for:

https://developer.android.com/reference/kotlin/android/provider/Settings



So, there it is, we need the SYSTEM_ALERT_WINDOW permission. (Which also is specified in the example code by Erel.)

Please let me know if you have input on how to improve this very small tutorial.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…