Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppState changes to background in android

I have integrated some code to handle a logic when the app is changing from foreground to background and vice versa. When the user navigates to the home screen we are requesting some permissions for location, camera and stuff from the user. The issue is in Android, in which when permission popups in the screen, app state changes to background, but I want the actual foreground -> background functionality to be triggered. I have used AppState in react native to achieve this functionality. It would be a great help if one can elaborate why the app is going to background when permission confirmation alerts popups? Thanks in advance.

like image 407
SVG Avatar asked Mar 02 '26 20:03

SVG


2 Answers

Flag the permission like whenever you are gonna ask permission make isPermissionAsk to true. and in AppState Listener - for callback function where you are doing you stuff add a check on top

if(isPermissionAsk)
{ changePermissionAsk(false); return;}
like image 191
Xhirazi Avatar answered Mar 05 '26 10:03

Xhirazi


In Android or iOS the permissions are OS managed features and the doesn't have any control other than requesting permission or getting state of permission. So when a permission is required you can think of permission app is in foreground which puts your app in background.

like image 22
Subramanya Chakravarthy Avatar answered Mar 05 '26 10:03

Subramanya Chakravarthy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!