Hello Reto
I am running you sample application on my Samsung Galaxy S2 with Android JB 4.1.2. When I run the application it runs fine and gets a list of earthquake data, and search works fine as well.
But as soon as I change something in the preferences e.g.
Set Auto refresh to false or the
Refresh Frequency etc and then try to close the application I get the Error message.
Quote:
Unfortunately, Earthquake has stopped
|
The message from ADB Logcat is shown below.
Code:
11-30 16:04:30.103: ERROR/AndroidRuntime(4295): FATAL EXCEPTION: main
java.lang.RuntimeException: Failure delivering result o activity {com.paad.earthquake/com.paad.earthquake.Earthquake}: android.os.NetworkOnMainThreadException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3267)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3310)
at android.app.ActivityThread.access$1100(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1254)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4906)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341)
at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486)
at com.paad.earthquake.EarthquakeListFragment.refreshEarthquakes(EarthquakeListFragment.java:90)
at com.paad.earthquake.Earthquake.onActivityResult(Earthquake.java:92)
at android.app.Activity.dispatchActivityResult(Activity.java:5192)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3263)
... 11 more
Please advise me on how to fix this error.
Regards
Khurram Majeed