I am having trouble using the ArcGISLocalTiledLayer. I am using the latest 10.2.2 version of the ESRI SDK for Android. I took code from the sample located here https://developers.arcgis.com/android/sample-code/export-tile-cache/. I am working on an application that will be disconnected from a network and needs to use its own internal maps. For now, I thought I could use the "Export Tile Cache" sample to download maps (when the user is connected to the network), and then use the internal TPK file that is generated when off the network. The code I took from the sample does generate a TPK file (which I will post), but when I initially try to use the file off network I get a: EsriStatusException[code: -1001, Message:The ArcGISTiledMapServiceLayer cannot be initialized
Below is the code I am using to switch over to local during initialization:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_view);
mapURL = getResources().getString(R.string.streetMapUrl);
defaultPath = this.getFilesDir().getAbsolutePath();
defaultPath += DEFAULT_BASEMAP_PATH;
File f = new File(defaultPath);
String database = null;
if(f.exists())
{
isLocalLayerVisible = true;
database = f.getAbsolutePath();
}
Intent parentIntent = getIntent();
setContentView(R.layout.map_view);
wgs84Ref = SpatialReference.create(SpatialReference.WKID_WGS84);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
startLocation = new Point(parentIntent.getDoubleExtra("longitude", -80.649691), parentIntent.getDoubleExtra("latitude", 28.095114));
dataFilterDistance = prefs.getInt(SettingsActivity.pk_culling_distance_m, 0);
// Retrieve the map and initial extent from XML layout
mMapView = (MapView)findViewById(R.id.map);
// Add dynamic layer to MapView
if(!isLocalLayerVisible)
onlineLayerId = mMapView.addLayer(new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
else
{
localTiledLayer = new ArcGISLocalTiledLayer(database);
localLayerId = mMapView.addLayer(localTiledLayer);
}
mGraphLayer = new GraphicsLayer();
graphicsLayerId = mMapView.addLayer(mGraphLayer);
mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
private static final long serialVersionUID = 1L;
public void onStatusChanged(Object source, STATUS status) {
// This is done because the project isn't setup till afterword
// THIS IS WHERE I SEE THE ERROR
if (OnStatusChangedListener.STATUS.INITIALIZED == status && source == mMapView) {
int blackColor = Color.rgb(Color.red(0),
Color.green(0), Color.blue(0));
SimpleLineSymbol line = new SimpleLineSymbol(blackColor,4.0f);
Polyline circle = createCircle(startLocation.getX(),startLocation.getY(),dataFilterDistance);
startLocation = convertToMap(startLocation);
filterDistanceCircle = new Graphic(circle,line);
filterDistanceCircleUUID = mGraphLayer.addGraphic(filterDistanceCircle);
startLocation = convertToDegrees(startLocation);
mMapView.centerAndZoom(startLocation.getY(), startLocation.getX(), 13);
}
}
});
setUpMap();
}
I have uploaded my TPK as a zip file. It worries me that the error I get back is having to do with the "ArcGISTiledMapServiceLayer " which is what I am using for Remote maps. I have verified that the code above does find the valid TPK file and skips past using my "ArcGISTiledMapServiceLayer" for online data and instantiates a "ArcGISLocalTiledLayer". What am I doing wrong or missing? Thanks in advance.