Hello,
I have an old Android application that display local .tpk file.
I try to rewrite the application using Java and ArcGis Runtime 100.15.4, I have no errors, but the .TPK file is not displayed.
The .TPK file is located in a folder on the phone and the code is below:
and the main.xml file:
It looks like you are using the wrong constructor to create your ArcGISTiledLayer. In order to create an ArcGISTiledLayer from a tpk file, use the constructor that takes a TileCache, see documention.
Hello,
Unfortunately it does not work. I tried with TileCache also, but nothing...
What is weird is that if I do not have the .tpk file ib the folder (I deleted for testing), the application does not stop with an error (file not found or something like that...), instead runs and display a blank white screen with ESRI logo in bottom-right corner. So, with or without .tpk file the application run in the same mode.
Below is the source code. Can anybody have any ideea how can I solve this?
To troubleshoot, please check the load status of your TileCache, like this:
TileCache tileCache = new TileCache(base);
tileCache.addDoneLoadingListener {
Log.d(TAG, ${tileCache.loadStatus})
if (tileCache.loadStatus == LoadStatus.FAILED_TO_LOAD) {
Log.d(TAG, ${tileCache.loadError?.message})
}
}
ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tileCache);
ArcGISMap map = new ArcGISMap(new Basemap(tiledLayer));
mmapView.setMap(map);
In addition, check out the following sample that uses a tpk file:
https://developers.arcgis.com/android/kotlin/sample-code/offline-routing/
Hello Gunther,
thank you very much!
I did the check and the .tpk file is not loaded, that's why I have a white balnk screen with or without the .tpk in location.
What can I do now? I need to provide read rights in the manifest file?
Thank you for helping me,
Regards,
Robert
What exactly is the load error you get back from tileCache.loadError?
> What can I do now? I need to provide read rights in the manifest file?
If your tpk file is located in shared storage, yes, you need to specify READ_EXTERNAL_STORAGE permission. Please refer to the Android documentation for details on storage.
The load error is: "com.esri.arcgisruntime.ArcGisRuntime Exception: File not found.:Package file not found"
I cannot use READ EXTERNAL STORAGE permission because I have Android 14 and this permission is deprecated and I don't know where I need to copy the .tpk files on the phone, in order to be found by application.
The application package name is com.example.reteaanp
It depends on you application requirements where you need to deploy your tpk file. If you can deploy it on app specific external storage or internal storage, you won't need to request any permissions to read the file. You can then use APIs like `getExternalFilesDir`: https://developer.android.com/training/data-storage/app-specific
More details on storing media files on app sepcific storage here: https://developer.android.com/training/data-storage/app-specific#media
If your tpk needs to be deployed on shared storage, you may need to request permissions to access all files:
https://developer.android.com/training/data-storage/manage-all-files
I don't need to deploy anywhere the .tpk files. I have the .tpk files, made with ArcGis Desktop v10.1. I must copy the .tpk files on the phone somewhere where these files can be found by the application and loaded into a TileCache and after that in a map that is displayed on the phone.
In the older version it was no problem. The .tpk files were in a folder in the phone and the application ran for many years without any problem.
Now I have difficulties because I tried to store the .tpk files into DCIM folder but the TileCache run into the error that "the file is not found".
The problem was solved, thank you Gunter! It was a permissions issue.