Runtime error to make pedometer

Since I am a beginner, I am getting difficulty to solve this problem. Please inform me how to figure out weight and step text box.
Thanks in advance.

Obviously you can't multiply empty string by "50".
You need to get int value from them.


Thank you for your info. Please check attached, no matter I put text or number, same runtime error came out. Please explain me how to fix it.


Thank you for your info. Please check attached, no matter I put text or number, same runtime error came out. Also if I put number on weight text box when initialize, on the phone it came out "0"--- does not disappear. Please explain me how to fix it.


Try using a Math Block rather than a Text Block as shown

and using the Math 0 might fix part of your issue. You may have to move call Player1.Start to the bottom of the Blocks in the event handler or temporarily disable the Player Block.

Otherwise post all your Blocks or your aia and someone might check.

pedometer.aia (621.8 KB)

Dear Steve,

Many thanks for your information. Now I am attaching as aia file.
If someone can help me to solve and explain, will be much appreciated.

There are problems in your Clock

pedometertest.aia (622.2 KB)

Made changes that may help you find your mistake. Disabled Clock, added simple pedometer code and no longer get the error; however this does not fix code in your Clock routine.

1 Like

Dear Steve,

Thanks for your kindness.
I still need to make the clock works and need to figure out the speed and Kcal label. If you have any additional information which I can try, please inform any time. Thanks. I am attaching current situation.

Dear Steve,

I think the clock is working, and I will make it correct steps and distance.
I hope we can keep in touch.....Thanks.

Dear Steve,
In these couple of days I tried to make something as attached. If you have any solutions, please inform me. Thanks.

Thanks for your images Khun.

Why your kcal does not display a number? A guess is your Clock is updating faster then App Inventor can keep up with the Step changes. Note kcal displays a number zero (this is your default value formatted to 15 digits)

Something is probably wrong with your kCal algorithm or because you only enable those actions only when if DistanceLabel /= 0 .

Why you have issues with Weight and Step display?
I do not know. A guess is you use TextBoxes to 'store' information instead of global variables. information. Some people use Labels and TextBoxes as 'variables'; that can work but sometimes it causes issues. That might be what is happening in your app.

You have made some progress. Keep experimenting. :slight_smile:

1 Like

Dear Steve,

Due to your support, I finally could complete my project as I expected. This is my first app in my life. I am so happy with it.

Only I am not satisfied is this pedometer sensor does not work accurately (when I walk 30 steps, it show only 15 or 20 steps). If I can find more sensitive and accurate pedometer sensor, it will be more interesting. If you know where and how I can find better pedometer sensor, please inform to me.

Great thanks.

1 Like

Yes, unfortunately, the Pedometer is based on the in-built Accelerometer, and is therefore not very reliable.

1 Like

Congratulations, the app looks nice although it is not working exactly like you would like.

The results possible with the Pedometer component depend to large extent on how good the accelerometer hardware is in your Android and how you adjust the StrideLength and how you keep the device from sleeping. I expect you will get better results when you walk a greater distance than 30 Steps. The Step sample size is very small. More steps would tend to smooth out the step issues. A better test would be to walk a known distance; possibly one kilometer. Walk that distance and compare your Distance(KM); how close to 1 km do you get?

Before MIT provided the Pedometer component (see Nishyanth's post), I made a pedometer using the Accelerometer. It is possible to adjust the sensitivity of the Accelerometer but not the Pedometer. As I recall, I got better results the Accelerometer and writing my on calclation using the Accelerometer than when using Pedometer.

A different way to measure distance walked would be to use the LocationSensor (gps) to keep track of how far you walk. If you know the distance walked and your stride length you can calculate the approximate number of steps.

Someone has created a free extension to make a Pedometer [FREE] Pedometer with Foreground Service . The extension might work better than the Pedometer component. I have not tried it.

Keep on experimenting. Let us know if you can improve your Walkie app.