-
Notifications
You must be signed in to change notification settings - Fork 124
Service stops when app is killed #19
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
Comments
The service works normally for actions that move to the background (back button, home button, screen off, remove from the list of recently launched apps, etc). But, service termination cannot be prevented by forcibly stopping the app in the processor manager or application information screen. |
In this article they say it is possible. Is this out of date? |
This plugin is already implemented in a similar way as in this article. I know that forced process killing by the user or the system cannot be prevented. If there is a better way, please let me know. |
Ah well I see. Thnx for your fast reply. Just one more question, is there a way to limit sensor requests? I tried to fetch only the first element in onStart callback of the stream and thought due to the foregroundTaskOptions it would restart again but it didn't. Example:
Expected behavior: Every 15th min I get the amount of steps of sensor. What did I wrong? |
The
So do the above code in @override
Future<void> onEvent(DateTime timestamp, SendPort? sendPort) async {
final pedometer = Pedometer.stepCountStream;
final StepCount event = await pedometer.first;
FlutterForegroundTask.updateService(
notificationTitle: 'Current steps', notificationText: '${event.steps}');
sendPort?.send(event);
} |
Ah great! Thnx again and nice lib! |
I am trying something similar, but when i try to access the Pedometer package (https://pub.dev/packages/pedometer) in my task handler it doesn't work. the sensor event listeners are not registered . I don't see any errors in the logs. |
As title says, the service is closed when the app is killed. Is this the right behavior? If so is there a way to prevent this?
The text was updated successfully, but these errors were encountered: