Skip to content

[android_alarm_manager] detect when background process is killed #39241

@hgouveia

Description

@hgouveia

Use case

I've a process in the background that is triggered by android_alarm_manager periodically every 10mins , this process might take a lot of time depending of the network connection, so i have a variable stored with "shared_preferences" called isWorking that is set to true when it starts and supposed to set to false when it finishes, so if another background process is triggered and is still working will be skipped

the issue is that sometimes, the user could clean all the apps for the task manager and suddenly kill the background process keeping the isWorking as true forever, even if not working anymore

Proposal

Would be great if is there any way to get an event on the background process when is about to be killed, probably related? https://stackoverflow.com/a/33078782/583718

or even better, a way to check the process status by id, since i can get the Insolate Id , i could store it also in "shared_preferences" and check the status in the next process, if the id is still alive, i can skip it until the next schedule , i've tried this but was never triggered, https://api.flutter.dev/flutter/dart-isolate/Isolate/addOnExitListener.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterp: android_alarm_managerThe Android background execution pluginpackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions