<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Trouble caching maps in a Service in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/trouble-caching-maps-in-a-service/m-p/662237#M4580</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far the API has been great, but I'm having trouble trying to complete a feature in my app.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create a service that runs an ExportTilesCacheTask on a time interval, the idea being that the app would automatically cache maps in the background so that the user still has a map available if they lose a data connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have already accomplished caching in the maps fragment itself, however transferring this code into a service has caused problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe the culprit is either the Envelope or the SpatialReference that I am passing into the ExportTileCacheParameters instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_1412630557993627" jivemacro_uid="_1412630557993627"&gt;
&lt;P&gt; final ExportTileCacheTask tileTask = new ExportTileCacheTask(serviceURL, cred);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Envelope extentToStore = new Envelope();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Location lastKnown;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; MainActivity.LocationServicesConnection locService = null;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; lastKnown = waitForLocation(locService);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; extentToStore.centerAt(new Point(lastKnown.getLatitude(), lastKnown.getLongitude()), 0.2, 0.2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ArcGISTiledMapServiceLayer layer = new ArcGISTiledMapServiceLayer(serviceURL, cred);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ExportTileCacheParameters params = new ExportTileCacheParameters(false, 15, 19, extentToStore,&amp;nbsp; layer.getSpatialReference());&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; createTileCache(params, tileTask, Environment.getExternalStorageDirectory().getPath() + DEFAULT_MAP_PATH);&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if I'm correctly creating the Envelope or the SpatialReference. Pulling the SR from a layer seems hacky and inefficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the logcat I first see a "FileNotFoundException" followed by errors in the callbacks from estimateTileCacheSize and generateTileCache.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code works perfectly in my map fragment, so I have to think it's the Envelope or SR causing this. Anyone?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Oct 2014 21:28:25 GMT</pubDate>
    <dc:creator>JeffJones1</dc:creator>
    <dc:date>2014-10-06T21:28:25Z</dc:date>
    <item>
      <title>Trouble caching maps in a Service</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/trouble-caching-maps-in-a-service/m-p/662237#M4580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far the API has been great, but I'm having trouble trying to complete a feature in my app.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create a service that runs an ExportTilesCacheTask on a time interval, the idea being that the app would automatically cache maps in the background so that the user still has a map available if they lose a data connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have already accomplished caching in the maps fragment itself, however transferring this code into a service has caused problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe the culprit is either the Envelope or the SpatialReference that I am passing into the ExportTileCacheParameters instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_1412630557993627" jivemacro_uid="_1412630557993627"&gt;
&lt;P&gt; final ExportTileCacheTask tileTask = new ExportTileCacheTask(serviceURL, cred);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Envelope extentToStore = new Envelope();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Location lastKnown;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; MainActivity.LocationServicesConnection locService = null;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; lastKnown = waitForLocation(locService);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; extentToStore.centerAt(new Point(lastKnown.getLatitude(), lastKnown.getLongitude()), 0.2, 0.2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ArcGISTiledMapServiceLayer layer = new ArcGISTiledMapServiceLayer(serviceURL, cred);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ExportTileCacheParameters params = new ExportTileCacheParameters(false, 15, 19, extentToStore,&amp;nbsp; layer.getSpatialReference());&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; createTileCache(params, tileTask, Environment.getExternalStorageDirectory().getPath() + DEFAULT_MAP_PATH);&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if I'm correctly creating the Envelope or the SpatialReference. Pulling the SR from a layer seems hacky and inefficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the logcat I first see a "FileNotFoundException" followed by errors in the callbacks from estimateTileCacheSize and generateTileCache.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code works perfectly in my map fragment, so I have to think it's the Envelope or SR causing this. Anyone?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 21:28:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/trouble-caching-maps-in-a-service/m-p/662237#M4580</guid>
      <dc:creator>JeffJones1</dc:creator>
      <dc:date>2014-10-06T21:28:25Z</dc:date>
    </item>
  </channel>
</rss>

