flutter_fgbg icon indicating copy to clipboard operation
flutter_fgbg copied to clipboard

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

Open madhav11194 opened this issue 3 years ago • 10 comments

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

madhav11194 avatar Dec 02 '21 04:12 madhav11194

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

ajinasokan avatar Dec 02 '21 05:12 ajinasokan

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.

ajinasokan avatar Dec 03 '21 10:12 ajinasokan

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.

madhav11194 avatar Dec 03 '21 13:12 madhav11194

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

ajinasokan avatar Dec 05 '21 06:12 ajinasokan

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

thorgexyz avatar May 26 '22 12:05 thorgexyz

@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.

ajinasokan avatar Jun 01 '22 12:06 ajinasokan

any progress?

hatemragab avatar Jul 12 '22 23:07 hatemragab

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?

abdallah-odeh avatar Apr 09 '23 10:04 abdallah-odeh

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

ajinasokan avatar Apr 10 '23 08:04 ajinasokan

Thank you for the quick respond, will try that.

abdallah-odeh avatar Apr 10 '23 08:04 abdallah-odeh