korzhuck

Crash. UnknownHostException when there is no connection.

Discussion created by korzhuck on Jul 18, 2012
That's how I use map in my app: 

     private com.esri.android.map.MapView _mapView;
     ////////////////////////////////////////////////////
    _mapView = (com.esri.android.map.MapView) view().findViewById(R.id.map);
    _tiledMapService = new ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer");

   _mapView.addLayer(_tiledMapService);
   /////////////////////////////////////////////////////

Then when there is no internet connection app crashes with Log:

E/ArcGIS  (15888): java.net.UnknownHostException: server.arcgisonline.com
E/ArcGIS  (15888):  at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
E/ArcGIS  (15888):  at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
E/ArcGIS  (15888):  at java.net.InetAddress.getAllByName(InetAddress.java:242)
E/ArcGIS  (15888):  at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
E/ArcGIS  (15888):  at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
E/ArcGIS  (15888):  at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
E/ArcGIS  (15888):  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
E/ArcGIS  (15888):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
E/ArcGIS  (15888):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:653)
E/ArcGIS  (15888):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627)
E/ArcGIS  (15888):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616)
E/ArcGIS  (15888):  at com.esri.core.internal.b.a.g.a(Unknown Source)
E/ArcGIS  (15888):  at com.esri.core.internal.b.a.g.a(Unknown Source)
E/ArcGIS  (15888):  at com.esri.core.internal.a.a.n.b(Unknown Source)
E/ArcGIS  (15888):  at com.esri.android.map.ags.ArcGISTiledMapServiceLayer.initLayer(Unknown Source)
E/ArcGIS  (15888):  at com.esri.android.map.ags.ArcGISTiledMapServiceLayer$1.run(Unknown Source)
E/ArcGIS  (15888):  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
E/ArcGIS  (15888):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/ArcGIS  (15888):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/ArcGIS  (15888):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
E/ArcGIS  (15888):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
E/ArcGIS  (15888):  at java.lang.Thread.run(Thread.java:1096)


As I see the crash caused by arcgis lib. So I can't catch it in my app.

Is there way to use arcgis runtime sdk with bad connection without crash?

PS Tested on the real device not emulator.

Outcomes