ExportTileCacheJob never starts

773
1
Jump to solution
02-15-2017 12:12 PM
CalebPourchot
New Contributor III

I'm using the .Net runtime sdk (v.100) for Xamarin Android. I'm trying to download tiles as a .tpk for offline use by my mobile app.

I've managed to use the AuthenticationManager to give me a token for my app. I can successfully create the ExportTileCacheTask and create the ExportTileCacheJob by calling ExportTileCache on the ExportTileCacheTask, but the status of the job never seems to change. When I check the job status immediately after the call to ExportTileCache, it is "NotStarted" and the ServerId = "". I have a breakpoint on my ExportJob_JobChanged handler and it never gets hit no matter how long I wait.

Any ideas? Code below:

var serviceUri = new Uri("https://tiledbasemaps.arcgis.com/arcgis/rest/services/World_Imagery/MapServer");
var tokenUri = new Uri("https://www.arcgis.com/sharing/rest");

try
{
var serverInfo = new ServerInfo
{
ServerUri = tokenUri,
TokenAuthenticationType = TokenAuthenticationType.OAuthClientCredentials,
OAuthClientInfo = new OAuthClientInfo { ClientId = MYCLIENTID, ClientSecret = MYCLIENTSECRET) },
};

AuthenticationManager.Current.RegisterServer(serverInfo);

var cred = await AuthenticationManager.Current.GenerateCredentialAsync(tokenUri, new GenerateTokenOptions { });

var exportTask = await ExportTileCacheTask.CreateAsync(serviceUri, cred);

var exportParams = await exportTask.CreateDefaultExportTileCacheParametersAsync(aoi, 50000, 10000);

job = exportTask.ExportTileCache(exportParams, localFilePath);

job.JobChanged += ExportJob_JobChanged;
}
catch (Exception e)
{
e.ToString();
}

0 Kudos
1 Solution

Accepted Solutions
CalebPourchot
New Contributor III

Apparently the tooltip documentation on ExportTileCache is misleading. It does not, in fact, Start and return an ExportTileCacheJob. You must call Start() on the job to start it.

I finally found java documentation of the class that mentioned this.https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/tasks/ti...

After calling Start(), the JobChanged events fired as expected and I was able to successfully download a .tpk file.

View solution in original post

0 Kudos
1 Reply
CalebPourchot
New Contributor III

Apparently the tooltip documentation on ExportTileCache is misleading. It does not, in fact, Start and return an ExportTileCacheJob. You must call Start() on the job to start it.

I finally found java documentation of the class that mentioned this.https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/tasks/ti...

After calling Start(), the JobChanged events fired as expected and I was able to successfully download a .tpk file.

0 Kudos