Make Android app wait for permissions

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ondesic

I have an android app the needs permission to access files. When I first install it, the permissions popup, but the app crashes.
After accepting the permissions, I can reopen the app fine.

Is there a way to pause the application in the background until the permissions are accepted?

May I ask how you’re even getting to the point of having the permissions request pop up? This is no request prompt popping up for me.

Dumuz | 2023-04-08 19:54

OS.RequestPermissions(); in C#
OS.request_permissions() in GDScript

ondesic | 2023-04-09 01:28

So, i can totally relate to the frustration of dealing with permission-related issues in Android apps. It’s essential to handle permissions properly to ensure smooth app functionality.

In response to the question about pausing the application in the background until the permissions are accepted, there isn’t a built-in mechanism to achieve this. However, there are approaches you can consider to address the problem.

One option is to implement a permission check before accessing any files and display a custom screen or dialog to the user, informing them about the required permissions and prompting them to grant them. Once the permissions are granted, you can proceed with normal app flow.

Another approach is to handle runtime permissions using the onRequestPermissionsResult() method. This allows you to request permissions and perform necessary actions once they are granted.

Remember to handle the scenario where permissions are denied. You can provide appropriate feedback to the user and request the permissions again if necessary.

Overall, it’s crucial to handle permissions gracefully, ensuring a seamless user experience while maintaining the security and functionality of your app.

angelacow | 2023-06-21 11:39

await get_tree().on_request_permissions_result

MainLoop — Godot Engine (stable) documentation in English
This will cause your app to wait until the user has accepted/denied the required permissions for your app.

blurrred | 2023-06-28 05:15