Unable to start navigation through intent to launch course from .FIT/.GPX file

Hello, I am calling an API that returns me .FIT file and I want to start the navigation right after I get the response for which I am receiving the data in onRecieve and there I am doing like this


function onReceive(responseCode, data){
      if (data != null) {
          System.exitTo(data.toIntent());
      }
}
where after calling System.exitTo(data.toIntent()); app gets a crash. also, I've tried using

var 
iterator = PersistedContent.getCources;
var course = iterator.next();
if (course != null) {
      System.exitTo(course.toIntent());
}
the same output here as well. Kindly help me here. 

Regards
Aafaq Ali.