SDL_RequestAndroidPermission(3)
π SDL_RequestAndroidPermission(3) π
okay bestie, you're in the SDL3 FUNCTIONS section of the SDL3 manual, and today's main character is SDL_RequestAndroidPermission β the one that asks Android for permissions at runtime, asynchronously. no cap. π«Ά
β¨ NAME β¨
SDL_RequestAndroidPermission β Request permissions at runtime, asynchronously. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_system.h>
bool SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata);
π¦ DESCRIPTION π¦
okay so first things first, bestie: you do not need to call this for built-in functionality of SDL. like, recording from a microphone or reading images from a camera using standard SDL APIs? that already manages permission requests for you. SDL is the responsible older sibling here. π
This function never blocks. literally never. instead, the app-supplied callback gets called when a decision has been made. and lowkey, that callback may happen on a different thread, and possibly much later, because it might be waiting on a user to respond to a system dialog. like, the user is out here living their life, staring at a popup, deciding your fate. π
If permission has already been granted for a specific entitlement, the callback will still fire β probably on the current thread and before this function returns. so don't go assuming silence means nothing happened. π
If the request submission fails, this function returns -1 and the callback will NOT be called. but ngl, that should only happen in catastrophic conditions, like memory running out. normally there will be a yes or no to the request through the callback. so most of the time it's giving... a decision. either way. π
For the permission parameter, choose a value from here:
https://developer.android.com/reference/android/Manifest.permission
that's the vibe check for what string to actually pass in. π
π FUNCTION PARAMETERS π
permissionβ the permission to request. πcbβ the callback to trigger when the request has a response. β¨userdataβ an app-controlled pointer that is passed to the callback. π«Ά
π₯ RETURN VALUE π₯
Returns true if the request was submitted, false if there was an error submitting. The result of the request is only ever reported through the callback, not this return value. so do not β I repeat, do NOT β read this as the answer to your permission question. it's just "did we manage to send the ask". periodt. π
π§ THREAD SAFETY π§
It is safe to call this function from any thread. main character energy from any thread. slay. π
β AVAILABILITY β
This function is available since SDL 3.2.0. so if you're on something older, no permission asking for you, bestie. π
okay that's the whole page, you ate it, go request some permissions responsibly. this was the SDL_RequestAndroidPermission(3) page from Simple Directmedia Layer, version SDL 3.4.18 β huge thanks to the SDL besties for keeping the docs iconic. bye babe! πβ¨ππ¦
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms