Build a fitness app with Ullis Foreground extension?

I tried to make a pedometer that stays active even if I close the app.
I think its measurements are not correct and when I start the measurement it gives me the measurement as shown in a picture, there at the point with the red circle it does not show the word calories.
Any thoughts on help?

The foreground extension allows the app to run in the foreground. If YOU close the app it will not remain active; this is NOT a way to make a background app. When you manually close the app; it will stop running. :cry: When the Foreground (KAS) service is activated: the app continues to count your steps when and after the device screen closes.

This appears to be Label4. I assume calories is determined by 0.045 times Label2.Text (the number of steps taken. Calories is not there in your app because you did not tell your app to place calories in Label4 by using a join Block.

How to build a Foreground Pedometer is described here

It works; your fitness app does not yet work.

The pedometer control is documented in Pedometer

Even though I close the application I also close the screen if I activate the stay alive it continues to count, it doesn't stop, but when it counts it doesn't show as I configured it in the designer.
I already have the application that is recommended here and I have been using it for a few days, I thought of making another one using the previous suggestions but it does not work as I would like and as shown in the pictures

1 Like

it does not look like Label10 are those blocks you marked with a red circle
it looks like you are confused?
btw. are you aware, that you can rename your components?

Label10 --> lblResult
Label 2 --> lblWalkSteps
Label4 --> lblMiles


I am really confused.
I'm re-uploading images with the name changes and the block piece, maybe I can fix it.
After the changes now it doesn't count calories at all

Here is in the design part how I would like it to appear

Here are the labels that will display steps, meters, miles and calories

and here is how it appears on my mobile

I think now it counts fine but the word calories keeps disappearing and only the calories that are supposed to be burned are shown

Which means, obviously you are updating the wrong label

What about using calNumb?


Wow, you helped me a lot, thank you so much.
I would now the words walk steps not to appear, only the word the steps

perhaps edit as shown

Now it counts e.g. 49 walk steps and 2.2 meters, I wasn't even a turtle
Also gone is the measurement in miles

In the design part I deleted the texts from the labels and it now appears like this.
I think that now it does not confuse with the double displays and that the counting of distances in relation to the steps is better.
But the pedometer counts steps even if you wave your hand up and down a bit.
This makes it not so reliable.

Yes, a user can force the steps to increment by doing silly things. Put your Android in your pants pocket and see if you can fool the app. I find it very difficult to do that. This pedometer is as reliable as my mechanical old fashioned step counter which means the Accelerometer is working correctly.

I do not agree. A step counter like this, on AVERAGE, provides accurate but perhaps not precise measurements. I am happy that it works as well as my son's step counter fitness app from Google. :wink:

You made a lot of progress modifying the original Foreground Pedometer. Congratulations.

1 Like

Yes the pedometer is useful everyday because I aim to walk every day. And thanks for that.
Thanks for your help too.
I might be a bit more difficult than all of you because I don't really understand most of the explanations and I lack the knowledge. With a little patience especially from me I will achieve something.
In this application I want to add the ability to save the measurements for as many days as I want and then be able to delete them.
I will try, but it seems very difficult.
What number should be added to make the measurement of distances in meters and miles closer to reality?

Uli extensions helped a lot here in this app.
It keeps counting even when I close the app and the screen turns off!

Calibrate your pedometer. The pedometer component assumes you have an average stride length of 0.73 meters. You can change this to whatever coincides with your actual stride length.

Returns the current estimate of stride length in meters, if calibrated, or returns the default (0.73 m) otherwise.

How to determine your stride length

Once you know the answer in meters you can set StrideLength to that value in your Screen1.Initialize block. This hard codes the value. You could also write code to select different strides for different strides or people using your app. :wink:

Is there an example to see how I can do this?
Because I have no idea how.
The help is very good to proceed very well.
If there is any sample, I would prefer with pictures, I could understand it very quickly.
Unfortunately I have not studied all of this and what I am learning, I am learning by educating myself in here with your help.

Average walking stride for a male is 0.4572 to 0.762 meters, the default setting for the pedometer is 0.73 meters.

What ranges you use is up to you to decide. Perhaps setting StrideLength to another value for stridelength will result in a calculation to miles or meters or kilometers walked closer to what you want to see. EVERYONE has a natural stride length based on male/female, age, physical height etc.

Here is a simple way to make the StrideLength of your app adjustable using a Spinner and a Label. How you can save this so the pedometer will remember a setting is up to you as are the values and number of options you include in the Spinner. :wink:

The ElementFromString block goes in your Screen.Initialize Block.

Experiment with different values for StrideLength until you find one you are happy with.

If you are not comfortable with this, once you find your usual stride factor, you can place the Pedometer1.StrideLength to whatever you want to work for your situation without the Spinner.

1 Like

I did as you suggested, but it takes me to the stride length option.

In ElementFromString I put these.

What should I fix so that the default 0 doesn't show me

For the step length option, is what it shows as you gave it correct?
Or did I make a mistake and it shows like this?

Stride Meters, low 0.4572m, default 0.73m, high 0.762m is all you need in the ElementsFromString Block.

Try it. There should not be a default 0.73m or 73m in the Spinner. The code provides only three options. You could add more.


replace the comma by dot


Why on a fixed sample of 41 steps does it give me a meter difference?
He put me at 0.762 with 3 times reading 3 different meters
The: 31.4m - 28.5m - 29.9m
In position: 0.73 he put me with 2 measurements of 29.2 meters and 30.7 meters also in 41 steps.
Shouldn't it be doing the same thing?
With such separation in the 41 steps, what will happen in the hundreds and thousands of steps?