Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Pedometer API - Native Step Counter

Discussion in 'Assets and Asset Store' started by Lanre, Jul 14, 2017.

  1. spaceowlpro

    spaceowlpro

    Joined:
    Nov 8, 2017
    Posts:
    6
    So it seems my pedometer only updates the step count after 5 or 6 steps, but it kinda fluctuates. What does everyone else here get and on what kind of phone?
     
  2. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    The native pedometer determines this. On some devices, the pedometer reports steps as they come in (in realtime); on other devices, the pedometer batches steps and sends updates with the aggregate count of steps. Pedometer API itself doesn't have any latency-inducing operations.
     
  3. spaceowlpro

    spaceowlpro

    Joined:
    Nov 8, 2017
    Posts:
    6
    Okay, thanks! Maybe I'll figure out how to use the accelerometer to pick up device shaking that happens when someone takes a step instead.
     
  4. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    This isn't an easy task, but you can try it.
     
  5. spaceowlpro

    spaceowlpro

    Joined:
    Nov 8, 2017
    Posts:
    6
    Right? If I get anything going, I'll say something here. If you don't hear from me in a week... you'll know. :p
     
    Lanre likes this.
  6. avcjeewantha

    avcjeewantha

    Joined:
    Feb 19, 2019
    Posts:
    1
    Hi, I have the same problem. Do you know how to do this?.
     
  7. locosagpro

    locosagpro

    Joined:
    May 14, 2019
    Posts:
    9
    upload_2019-5-14_14-30-17.png

    i need use this api , but send this error
    i want build in android apk
     
  8. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    Find libPedometer.a in your project, and in the inspector, make sure that it only applies to iOS.
     
  9. locosagpro

    locosagpro

    Joined:
    May 14, 2019
    Posts:
    9
    download the api, do not modify its code, I only want to use it for android but it throws me the previous error, what can it be?
     
  10. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    Do what I described above. Unity thinks it should build the iOS library for Android which is incorrect.
     
  11. locosagpro

    locosagpro

    Joined:
    May 14, 2019
    Posts:
    9
    I managed to generate the apk, but it does not tell me the steps in my cell phone, I tried with other api and if it works, I have a samsung j5 pro
     
  12. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    Check the logs for clues.
     
  13. locosagpro

    locosagpro

    Joined:
    May 14, 2019
    Posts:
    9
    I've this ,the cell phone does not count the steps
    upload_2019-5-15_0-28-30.png
     
    Last edited: May 15, 2019
  14. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    I mean the logs from adb logcat.
     
  15. locosagpro

    locosagpro

    Joined:
    May 14, 2019
    Posts:
    9
    i have this
    need to use this api
    I feel lost and it does not work
    help me pls
    upload_2019-5-16_0-56-36.png
     
  16. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,841
    I noticed a slight error on the sample code on GitHub. This line:
    Code (CSharp):
    1. distanceText.text = (distance * 3.28084).ToString("F2") + " ft";
    should be this:
    Code (CSharp):
    1. distanceText.text = (distance / 3.28084).ToString("F2") + " ft";
    Multiplying is saying that feet are bigger than meters, when in fact feet are smaller than meters.
     
  17. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
  18. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    Not quite.
     
  19. locosagpro

    locosagpro

    Joined:
    May 14, 2019
    Posts:
    9
  20. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    It doesn't look like a permissions issue. Other apps might fall back to different methods to detect steps, like GPS.
     
  21. locosagpro

    locosagpro

    Joined:
    May 14, 2019
    Posts:
    9

    Do you have any version with gps?
    I need this urgently
    I'd appreciate it a lot
     
  22. locosagpro

    locosagpro

    Joined:
    May 14, 2019
    Posts:
    9
    upload_2019-5-16_13-37-32.png
    change the line of code and the above mentioned error does not appear
    but do not count the steps
     
  23. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    The old 1.0 version falls back to GPS.
     
  24. locosagpro

    locosagpro

    Joined:
    May 14, 2019
    Posts:
    9
    It has many errors :(
     
  25. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    I don't maintain it anymore. You can create a custom GPS implementation based on the code in that branch.
     
  26. ArmanUnity

    ArmanUnity

    Joined:
    Nov 29, 2015
    Posts:
    21
    Do we have a function/code to check whether user has denied permission for motion usage???? @Lanre
     
  27. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,602
    There currently isn't a function for this. You can create an issue for this on GitHub.