1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Android os_request_permission issue [solved]

Discussion in 'GameMaker Studio 2 Community Tech Support' started by silentworks, Nov 2, 2019.

  1. silentworks

    silentworks Member

    Joined:
    Jul 27, 2016
    Posts:
    18
    I am trying to request a permission at runtime using

    Code:
    os_request_permission("android.permission.WRITE_EXTERNAL_STORAGE");
    but the requester does not appear. Can somebody please confirm this?
     
  2. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,426
    The documentation suggests that WRITE_EXTERNAL_STORAGE can be requested via Game Options instead, so perhaps it does not appear if you've asked for it there?
     
  3. silentworks

    silentworks Member

    Joined:
    Jul 27, 2016
    Posts:
    18
    Thanks.

    I also tried to check the permission checkboxes in the Game Options, however I still need to request the permission at runtime (just before I need to access the external storage) so I need to use the os_request_permission function.
    From API 23 (I am targeting 29) permissions should be granted at runtime instead of installtime, so I just cannot use the Game Options for this.

    I've made more investigation and found the os_check_permission function returns -1 so the following condition will never will be true as os_permission_denied constant is 0:

    Code:
    if os_check_permission("android.permission.WRITE_EXTERNAL_STORAGE") == os_permission_denied
    ...

    Instead I am using:

    Code:
    if os_check_permission("android.permission.WRITE_EXTERNAL_STORAGE") != os_permission_granted
    ...
    Now the requester seems to be fine.
     
  4. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,977
    Please file a bug report about this.
     

Share This Page

  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