StepCounter sensor not working?

180 views
Skip to first unread message

Khairul Aiman

unread,
Jun 29, 2023, 9:45:00 PM6/29/23
to DroidScript
I'm trying to make an app that can track steps.
However the StepCounter sensor doesn't seems to be working...

Even though my phone does support the sensor...

Alan Hendry

unread,
Jun 30, 2023, 6:50:42 AM6/30/23
to DroidScript
HI,
First I'd use GetNames to check the sensor name (it may be case sensitive)
Next check debug for messages (touch the bug icon, or debug window in WiFi IDE)
If that fails then you can post a sample of test code here
Also see 
Regards, ah

Khairul Aiman

unread,
Jun 30, 2023, 10:35:16 PM6/30/23
to DroidScript
Debug is empty...

I heard that you need activity recognition permission.
If that's the reason, how?

My code looks like this:

function OnStart()
{
var check = app.CheckPermission( "Body" );
app.GetPermission( check )

lay = app.CreateLayout( "Linear", "VCenter,FillXY" );


txt = app.CreateText( "", 0.8, 0.3, "Multiline" );
lay.AddChild( txt );
app.AddLayout( lay );


sns = app.CreateSensor( "StepCounter" );
sns.SetOnChange( sns_OnChange );
sns.Start();
}


function sns_OnChange( x, y, z, time )
{
txt.SetText( "x=" + x + "\n y=" + y + "\n z=" + z );

Alan Hendry

unread,
Jul 1, 2023, 11:33:24 AM7/1/23
to DroidScript
HI,
When you run directly under DS then it uses DS's permissions to Android functions.
When you build (as APK or AAB) then the builder reads your code,
creates a list of required permissions, and adds them to the manifest.xml
(when a user installs the app then the manifest is used to get the users permission
to use these functions).
Probably needs the official/technical team.
They may need to know the version of Android, version of DS
Regards, ah

Steve Garman

unread,
Jul 2, 2023, 1:42:53 AM7/2/23
to DroidScript
You might want to keep an eye on the thread at https://groups.google.com/g/androidscript/c/4z_CqHfx6Cs/m/l7FGEVidAgAJ to see if anything comes up

Khairul Aiman

unread,
Jul 2, 2023, 2:12:53 AM7/2/23
to DroidScript
Thanks!
Reply all
Reply to author
Forward
0 new messages