Distance in Km

Former Member
Former Member
In want display the Distance (from ActivityInfo) on my Watchface. It works, but in get the distance in cm. How can i change it to Km as float (z.B. 3,32)?
  • Here's how I do both miles and km's
    if(settings.distanceUnits==Sys.UNIT_STATUTE) {
    string=(activityInfo.distance/160934.0).format("%.2f")+" mi";
    }
    else {
    string=(activityInfo.distance/(100000.0)).format("%.2f")+" km";
    }
  • Former Member
    Former Member over 9 years ago
    Doesn't works

    Here's how I do both miles and km's
    if(settings.distanceUnits==Sys.UNIT_STATUTE) {
    string=(activityInfo.distance/160934.0).format("%.2f")+" mi";
    }
    else {
    string=(activityInfo.distance/(100000.0)).format("%.2f")+" km";
    }


    I get the message:
    Could not find symbol settings.
    Symbol Not Found Error

    May i have to create a settings.xml first? But what schuld i type into the xml?
  • I get the message:
    Could not find symbol settings.
    Symbol Not Found Error


    You need this: (I do it early in the code so I missed copying that line)
    var settings=Sys.getDeviceSettings();
  • Former Member
    Former Member over 9 years ago
    You need this: (I do it early in the code so I missed copying that line)
    var settings=Sys.getDeviceSettings();


    Now it's perfect. 1000 Thanks
  • There's a bunch of useful stuff in device settings. That's where you can find things like 12/24 hr mode, the alarm count, notifications count., and bluetooth status. You may want to look there to see other things you want for your watchface.