Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin reporting that the app is in background, while opening take image and pick Image. #5

Open
madhav11194 opened this issue Dec 2, 2021 · 10 comments

Comments

@madhav11194
Copy link

madhav11194 commented Dec 2, 2021

I tried running the example project in android emulator and it is giving same result as AppLifeCycleState. i.e, showing that the app is in background for image picker and then foreground when image picker is closed.
Screenshot_1638420688

@ajinasokan
Copy link
Owner

Yes there seems to be a problem. Will investigate this.

@ajinasokan
Copy link
Owner

It seems image picker is now opening a different app/package for both camera(opens camera app) and file picking(open file manager) and not an activity on top of Flutter app. So app IS going to background that's why the plugin reported that way as well.

I guess now it will be useful only in case of the biometric auth flow or any other lib that has activity based pickers.

@madhav11194
Copy link
Author

Thank you ajin for replying. So now I'm using AppLifeCycleState only. And the function which is opening image picker, I am using an if/else conditional, to not the call the required function, which I need to call for app inactivity, at that time. So, It's working fine.

@ajinasokan
Copy link
Owner

Alright. I will keep this issue open until we there is a proper fix/decision.

@thorgexyz
Copy link

flutter_fgbg is reporting that the app enters fg/bg when authenticating with passcode on my Android (ONEPLUS A5000 (mobile) • db8f9f95 • android-arm64 • Android 10 (API 29)) with local_auth

@ajinasokan
Copy link
Owner

@thorgexyz Does that open another app/activity that is not part of your app? Then it would report as foreground/background switch, because it is in fact a foreground/background switch.

What is not such a switch is, an overlay that shows up above your app or an activity/fragment that is part of the app showing above/instead of your Flutter view.

As I see more reports like this I'm assuming the manufacturers customize these things and this library is not very effective in every scenarios.

@hatemragab
Copy link

any progress?

@abdallah-odeh
Copy link

any progress yet?
the plugin reports bg/fg switch when the user tries to pick an image from gallery or files, in android it fires that the app is in background
it works fine when opening camera,
in iOS it works perfectly

did you find a solution for that? or anyone has a workaround?

@ajinasokan
Copy link
Owner

I have written a workaround (read as a nasty hack I'm not proud of)

You can use the new FGBGEvents.ignoreWhile API like this:

FGBGEvents.ignoreWhile(() async {
    await picker.pickImage(source: ImageSource.gallery);
    // or do something else that can put app to background but don't want to be handled by flutter_fgbg
});

Any background foreground switches while the closure is executing will be suppressed. This is available in the master. Test it with this in pubspec and let me know if it works, I will make a new release.

    flutter_fgbg:
        git:
            url: https://github.com/ajinasokan/flutter_fgbg
            commit: 19957b21bcf26bbc85cd73e02008afa053ef5c2c

@abdallah-odeh
Copy link

Thank you for the quick respond, will try that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants