To build a step counter app using Android studio.

Thread Starter

Lemon_Foam

Joined Sep 18, 2017
39
can anybody shown me how to build an step counter app using android studio that will count the number of footstep and plot the number of footstep in graphical form for every 15 minutes?
 

Thread Starter

Lemon_Foam

Joined Sep 18, 2017
39
1234.PNG
Here is part of code, i wish to calculate number of step added for every 15 minutes no matter the sensor detect motion or not, and save it in 'numStepsAdd' and diaplay it. Then, update the latest number of steps into 'numStepsA' 1 minutes after displaying the 'numStepsAdd', so that i can use the formulae
'numStepsAdd=numSteps-numStepsA' to calculate numStepsAdd every 15 minutes. Then, repeat whole process for every 15 minutes.

But after i build my app, it will only show step added after every 15 minutes if the sensor detect steps, if the sensor does not detect any steps, the app will not show any changes in the 'numStepsAdd' until sensor detect steps is made.
But what i want is to show the number of steps added every 15 minutes no matter sensor detect steps or not. For example if there are 5 steps added, 'numStepsAdd' show 5, when there are no steps added, 'numStepsAdd' show 0, for every 15 minutes.

So, can sir tell me what is wrong in my code, and help me to do some correction on my code.
 

MrSoftware

Joined Oct 29, 2013
2,013
Look at the code that updates your GUI. Now figure out what is required to happen for that code to execute. hint: will it execute even if no steps are taken?

GUI is not my strongest point, but try this. Create a timer that expires every 15 minutes. When the timer expires, use that event to execute the code that updates your GUI. If possible, move your step counting code off of the main thread.
 
Top