How to simulate Activity Data for User Profile Activity Data.

I want to get the distance of my latest run and display it in my own watch face. For this, I want to use a userActivityIterator to go through the stored Activities in the User Profil. However, I do not understand how I can play in some activities in the simulator... I see the activity simulation option in the CIQ Simulator, still don't understand how e.g. Running/Biking activities can be imported? How can I get an overview about the "latest activities" stored in the simulator? Is there a list or an option how the stored activities can be edited or seen?

  • This is something where I'd test with a sideload on a real device, as the sim uses hard codes info for some things

  • Alright. Thanks a lot! I tried your advice and looped over all user profil activies with that code to display the latestes distances for each sport (run, swim, bike) on my watchface. 

         
        var refreshDuration = (new Time.Duration(5)).value();
        var userActivityIterator = UserProfile.getUserActivityHistory();
        var activity = userActivityIterator.next();
    
        if (nowTime >= latestRefreshTime + refreshDuration) {
          while (activity != null) {
            if (
              activity.startTime == null ||
              activity.type == null ||
              activity.duration == null ||
              activity.distance == null
            ) {
              System.println("skip messy data");
              activity = userActivityIterator.next();
              continue;
            } else {
              i += 1;
              System.println("i: " + i);
    
              startTime = activity.startTime;
              activityType = activity.type;
              duration = activity.duration;
              distance = activity.distance;
              System.println("sample: " + startTime);
    
              if (
                activityType == Activity.SPORT_RUNNING &&
                startTime.greaterThan(latest_run_start_time)
              ) {
                distance_run = activity.distance;
                latest_run_start_time = activity.startTime;
              }
              if (
                activityType == Activity.SPORT_CYCLING &&
                startTime.greaterThan(latest_bike_start_time)
              ) {
                distance_bike = distance;
                latest_bike_start_time = activity.startTime;
              }
              if (
                activityType == Activity.SPORT_SWIMMING &&
                startTime.greaterThan(latest_swim_start_time)
              ) {
                System.println("Swim Activity refreshed");
                distance_swim = distance;
                latest_swim_start_time = activity.startTime;
              }
            }
            activity = userActivityIterator.next();
          }
    
          latestRefreshTime = Time.now().value();
          System.println("Latest refresh time: " + latestRefreshTime);
        }



    When I try it on my watch, I get really weird distances, which don't represent any of my (latest) activities. Do you have any explanation or do you see any obvious mistakes? 

    Do you recommend it the same way or do you recommend going via a OnActivityComplete() Method?

    Thanks!
    Michael
  • Remember, the distance you are seeing is in meters,  You may want to convert that to miles or kms.

  • Thanks again. Unfortunately, it's not the bug - I did check this before on the documentation site and want to have it in meters/kms

  • I remember that when I filtered the body battery history there were also garbage data. You'll need to log all the record and try to find the field that you can use to differentiate between garbage and real data and filter according to that field.

  • Hi Gavriel, 
    Thanks for your answer! Seems like this will be much more complicated than i thought :)