Android Tutorial How to determine needed permissions from JavaObject code

Discussion in 'Tutorials & Examples' started by Sandman, May 28, 2018.

  1. Sandman

    Sandman Well-Known Member Licensed User

    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

    upload_2018-5-28_11-53-14.png

    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.
     
    Emme Developer and Ohanian like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice