Skip to content
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

[pedometer 2.0.2] Add a pedometer that uses accelerometer #262

Open
thevirtuoso1973 opened this issue Jan 16, 2021 · 10 comments
Open

[pedometer 2.0.2] Add a pedometer that uses accelerometer #262

thevirtuoso1973 opened this issue Jan 16, 2021 · 10 comments
Labels
improvement an improvement

Comments

@thevirtuoso1973
Copy link

thevirtuoso1973 commented Jan 16, 2021

Description

For users of Android phones that do not have a step counter, provide an alternative step count stream that uses the linear accelerometer. It could be implemented by a service, where the alternative step count stream will have events sent to it while the service is running.

Additional information

I've already implemented this feature in my fork, and was thinking of publishing my fork since the feature may be outside the scope of what this pedometer package wishes to achieve. But I thought I should let you know in case you wish to accept a PR on this. (You may get users complaining that it is inaccurate 🙃.)

@thevirtuoso1973 thevirtuoso1973 added the improvement an improvement label Jan 16, 2021
@sumeetkumar1
Copy link

I was using this pedometer dependence in my application I think there is an issue It doesn't seem to work. I am not able to figure out what the issue in could you please help me out.

@thevirtuoso1973
Copy link
Author

(I'm assuming you're talking about my fork.)
I should probably document it better, but essentially you need to:

  1. Call startPlatform (which starts a service)
  2. Use the altStepCountStream instead of the stepCountStream.
  3. Call stopPlatform when needed. Note: you need to leave it on for the steps to be tracked.

So in an app you may wish to call hasStepCounter to check if they don't have it, then use the described method instead of stepCountStream.

Refer to this:
https://github.com/thevirtuoso1973/flutter-plugins/blob/master/packages/pedometer/lib/pedometer.dart

@sumeetkumar1
Copy link

I have used this to build the pedometer functionality. The problem only comes when the application is being run on a oneplus 7 pro. I am not sure if it because I need to ask permission or something else. The steps tracking works well on my other Samsung phone but that phone is rooted.

error on the oneplus device:
unregisterListenerImpl callingApp flutter

@sumeetkumar1
Copy link

Ill try using alternative stream and see if that solves the issues.

@thevirtuoso1973
Copy link
Author

thevirtuoso1973 commented Apr 7, 2021

If you are using my version, it may be better to create an issue on my repo: https://github.com/thevirtuoso1973/flutter-plugins
If you are talking about the normal pedometer (this repo, https://github.com/cph-cachet/flutter-plugins) then you should create a new issue on this repo.

@sumeetkumar1
Copy link

Well I doesn't matter which repo I am using I am getting the same error.

error:
E/SensorManager(10541): unregisterListenerImpl callingApp: com.inpaqt.t2dm,callingPid:10541,callingUid:10527
E/SensorManager(10541): registerListenerImpl sensorName:pedometer Non-wakeup,isWakeUpSensor:false,callingApp: com.inpaqt.t2dm,callingPid:10541,callingUid:10527
E/SensorManager(10541): unregisterListenerImpl callingApp: com.inpaqt.t2dm,callingPid:10541,callingUid:10527
E/SensorManager(10541): registerListenerImpl sensorName:pedometer Non-wakeup,isWakeUpSensor:false,callingApp: com.inpaqt.t2dm,callingPid:10541,callingUid:10527

@sumeetkumar1
Copy link

I have fixed the issue. This message comes when the user needs to give permission to the application to access the sensor at run time.

@sumeetkumar1
Copy link

Hello, I was trying to implement your alternative flow in the application I am working on. When I call the Pedometer.startPlatform(); It shows this error:

Unhandled Exception: MissingPluginException(No implementation found for method startPlatform on channel pedometer/alt_pedometer)
E/flutter ( 890): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:7)
E/flutter ( 890):
E/flutter ( 890):

Could you please help me with this.

@alexmercerind
Copy link

I've already implemented this feature in my fork.

Bravo! 👏👏👏

@alexmercerind
Copy link

https://github.com/alexmercerind/flutter-plugins/tree/master/packages/pedometer

I further worked on the fork & implemented the accelerometer based solution as a fallback to the same stream(s).
Both, step count & state is being fetched using accelerometer if physical step sensor is not present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement an improvement
Projects
None yet
Development

No branches or pull requests

3 participants