Closed smallstepman closed 3 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.
I have the same problem. Is there a workaround?
I also have the same problem... need help!!
You can use a foreground service. This works. But on some devices, for https://pub.dev/packages/pedometer an additional app such as Health or Google Fit is required :-(
Is there a solution for this?
Did someone find any solution ?
I am facing this issue too. Is there any solution for this?
@christocracy attention needed!
Provide a simple test-case App that demonstrates your problem, in a public github repo.
You guys can use flutter_foreground_service_plugin for getting the pedometer steps. I was stuck in this problem for days but then I tried foreground service and it worked.
You guys can use flutter_foreground_service_plugin for getting the pedometer steps. I was stuck in this problem for days but then I tried foreground service and it worked.
can you share your solution ?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.
I need help with the same issue. I want my pedometer app to run in the background. It should continue to count even when the application is covered.
I want my pedometer app to run in the background.
That's not what background_fetch does. It runs a periodic callback (fastest is once every 15 min). When the callback runs, it has 30s of background time before your app is suspended until the next event.
Anyway, pedometer api is always recording. You can query the api with a start/end datetime to receive the pedometer data the OS stored during that time.
I want my pedometer app to run in the background.
That's not what background_fetch does. It runs a periodic callback (fastest is once every 15 min). When the callback runs, it has 30s of background time before your app is suspended until the next event.
Anyway, pedometer api is always recording. You can query the api with a start/end datetime to receive the pedometer data the OS stored during that time.
Thank you for your answer. I want to show the steps taken with the non-deletable notification to the user. How can I do it.
How can I do it.
I have no idea (I've never used pedometer api) but background_fetch is not going to help with that.
I want my pedometer app to run in the background.
That's not what background_fetch does. It runs a periodic callback (fastest is once every 15 min). When the callback runs, it has 30s of background time before your app is suspended until the next event.
Anyway, pedometer api is always recording. You can query the api with a start/end datetime to receive the pedometer data the OS stored during that time.
Where can I find the API where I can query the pedometer data with a start/end date? The pedometer package only provides events as far as I know.
Where can I find the API where I can query the pedometer data
I don't know about Android, but the iOS CMPedometer
API has a method queryPedometerData(from:to)
I have never used this API, I only know that it exists. You will have to consult the documentation of your pedometer
package to learn more.
Hi, first of all, thank you for your work! This probably isn't about the issue with your package. I'm trying to build an Android Flutter app that will collect pedometer data. I'm at the beginning of my journey with Flutter so I wanted to use as many ready-to-use components as possible, therefore I picked this package https://pub.dev/packages/pedometer for getting data about the steps. Everything works beside one thing: I can't collect data while app is not running. I'm trying to use background_fetch to hopefully catch the amount of steps provided by this package, no matter if app is running or not, but without the luck. I'm also not the first one trying to do it https://github.com/cph-cachet/flutter-plugins/issues/60, other people tried to do it with workmanager and alarm manager but also couldn't make it work. Given your amount of experience with background processing and data from sensors on both flutter and android, I figured you might be the right person to ask for help.
Here are some details if you have time for it: Pedometer package implementation on flutter side: https://github.com/cph-cachet/flutter-plugins/blob/master/packages/pedometer/lib/pedometer.dart and on Native side: https://github.com/cph-cachet/flutter-plugins/blob/master/packages/pedometer/android/src/main/java/cachet/plugins/pedometer/PedometerPlugin.java and my code below. Please note that I'm using Mobx in my app to manage state. Mobx uses concept of Stores. My store that handles state of pedometer is called
Steps
. For that storeSteps
, there is a bunch of generated code insteps.g.part
file. This code was generated by issuing a commandflutter packages pub run build_runner watch
. I've tried to provide you with minimal working code, but I couldn't figure out how to make it work without Mobx, as I failed at the stage of making pedometer example app run - I'm unsure what is the issue. If that Mobx code makes it impossible for you to debunk this, please, let me know and I'll do my best to provide you with minimal setup/clonable repo Your Environmentflutter info
,flutter doctor
):Code
main.dart
database.dart
steps.dart
steps.g.dart
pubspec.yaml
Debug logs Here is the screenshot of the app. You can differentiate records into 4 groups
_MyAppState.initState()
_onBackgroundFetch
backgroundFetchHeadlessTask
Above shows that your plugin is working perfectly, but I'm unable to get my data. I'd love to know how to get some steps data in backgroundFetch and HeadlessTask, instead of
null
. Is there something wrong with the way I'm trying to do this? Or the implementation of pedometer package makes it unable to work without application context, and if so, how would one approach fixing it?