Hi,
We are trying to migrate one of our applicatoin from v10.2.9 to v100.1. We need to support map formats that are currently unsupported in the new runtime (i.e. : MBTiles). In our case, the system is always offline and the map are stored locally on the Android device.
It was easy to do that in the previous version (Creating a custom TileServiceLayer in ArcGIS Android | ArcGIS Blog ), but I had no success so for on the new v100.1.
I tried to extend the ImageTiledLayer, but I get an exception when I try to create a TileInfo using the following code :
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">static</SPAN> ImageTiledLayer <SPAN class="token function">createMBTilesLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">final</SPAN> Uri databaseUri<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">final</SPAN> SQLiteDatabase database <SPAN class="operator token">=</SPAN> SQLiteDatabase<SPAN class="punctuation token">.</SPAN><SPAN class="token function">openDatabase</SPAN><SPAN class="punctuation token">(</SPAN>databaseUri<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getPath</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> null<SPAN class="punctuation token">,</SPAN> SQLiteDatabase<SPAN class="punctuation token">.</SPAN>OPEN_READONLY<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ErrorHandler</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">final</SPAN> <SPAN class="keyword token">int</SPAN> maxLevel <SPAN class="operator token">=</SPAN> <SPAN class="token function">retrieveMaxLevel</SPAN><SPAN class="punctuation token">(</SPAN>database<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">final</SPAN> List<SPAN class="operator token"><</SPAN>LevelOfDetail<SPAN class="operator token">></SPAN> levelOfDetails <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArrayList</SPAN><SPAN class="operator token"><</SPAN><SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">for</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">int</SPAN> i <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN> i <SPAN class="operator token"><</SPAN> maxLevel<SPAN class="punctuation token">;</SPAN> i<SPAN class="operator token">++</SPAN><SPAN class="punctuation token">)</SPAN>
levelOfDetails<SPAN class="punctuation token">.</SPAN><SPAN class="token function">add</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">LevelOfDetail</SPAN><SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">156543.032</SPAN> <SPAN class="operator token">/</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">pow</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> i<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">554678932</SPAN> <SPAN class="operator token">/</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">pow</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> i<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">final</SPAN> TileInfo tileInfo <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">TileInfo</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">96</SPAN><SPAN class="punctuation token">,</SPAN> TileInfo<SPAN class="punctuation token">.</SPAN>ImageFormat<SPAN class="punctuation token">.</SPAN>JPG<SPAN class="punctuation token">,</SPAN> levelOfDetails<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Point</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> SpatialReferences<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getWebMercator</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">256</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">256</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">MBTilesLayer</SPAN><SPAN class="punctuation token">(</SPAN>tileInfo<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Envelope</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="operator token">-</SPAN><SPAN class="number token">180.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">85.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">180</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">85</SPAN><SPAN class="punctuation token">,</SPAN> SpatialReferences<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getWebMercator</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> database<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>java.lang.RuntimeException: Unable to start activity ComponentInfo{}: com.esri.arcgisruntime.ArcGISRuntimeException: Invalid argument
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2456)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2539)
at android.app.ActivityThread.access$900(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1384)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5507)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: com.esri.arcgisruntime.ArcGISRuntimeException: Invalid argument
at com.esri.arcgisruntime.internal.jni.CoreTileInfo.nativeCreateWith(Native Method)
at com.esri.arcgisruntime.internal.jni.CoreTileInfo.<init>(SourceFile:72)
at com.esri.arcgisruntime.arcgisservices.TileInfo.<init>(SourceFile:121)
...
Is it the right approach to support other tiled format ? Is it some obvious error in the code snippet above that I do not see ?
Regards,