JulianAssmann / flutter_background

A flutter plugin to keep apps running in the background via foreground services. Android only.
https://pub.dev/packages/flutter_background
MIT License
89 stars 52 forks source link

Foreground Service closes after app swiped up/closed from multitasking panel #59

Closed fahidsarker closed 2 years ago

fahidsarker commented 2 years ago

The plugin works fine when the app is focused or in the background. But once, once the app is closed by swiping up from the multitasking area, the notification is removed.

APP in Focus: Screenshot_20220622-215224__01

App In Background but not closed: Screenshot_20220622-215234__01

App Closed from muli-tasking view: Screenshot_20220622-215240__01

Note: The white dot is the notification

Is this normal behavior? Shouldn't it keep the app alive even after swiped up?

Objective of the app: Prevent the app from being killed to ensure timely alarm firing by the android alarm manager

Device: Oneplus 7 - Android 11

JulianAssmann commented 2 years ago

This is intentional behavior introduced by #10. As closing the app is an intentional action by the user, this intent has to be respected by apps. The isolate the app runs in should be killed either way, so keeping the foreground notification probably does not achieve the desired effect. See #28 for more. I don't quite understand the reason you need the app running in the background in order for the alarm manager to work.

fahidsarker commented 2 years ago

I see. Thank you for clarification.

The thing is Android probably kills my app process after it has been closed for few days. It is a prayer notification app, so notifying prayer time everyday and calculating the next time should continue happening even if user does not open the app for weeks. But, Alarm manager does not fire alarms on due time. Hence, I wanted to keep a process running to make sure it keeps running. Any help would be appreciated ðŸ¤