ActivityInfo inside an app

Hi guys,

I've just about finished my paramotor flying app, but while this snippet works in the simulator, it crashed the app on the device:

var activityInfo = Act.getActivityInfo(); -< this line crashes

if (activityInfo!=null){
Sys.println("elapsedTime" + activityInfo.elapsedTime);
distanceFlown = activityInfo.elapsedDistance/1000/1.609;
distanceFlownFormatted = distanceFlown.format( "%.01f" );
}


So - have I just got the wrong end of the stick about activities? The docs arn't great, but my the simulator behaviour I assumed that an activity was automatically started when my apps started ?

There seems to be no way of actually starting/creating an activity from within an app ?

Again, I'm probably missing something - but I want to grab the distance travelled in the activity ideally. As I'd be wanting to save the activity at the end of my flight.

any help ?