Wrox Programmer Forums
|
BOOK: Professional Android 4 Application Development
This is the forum to discuss the Wrox book Professional Android 4 Application Development Reto Meier; ISBN: 978-1-1181-0227-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android 4 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2012, 07:30 AM
Registered User
 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Chapter 9 Earthquake Part 3

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 7 Earthquake 2, Earthquake.java, error onActivityResult dbomberg BOOK: Professional Android 2 Application Development 2 November 30th, 2012 05:52 AM
Earthquake chapter 7 part 2 layingincouch BOOK: Professional Android 4 Application Development 1 October 31st, 2012 05:54 PM
Chapter 9 Earthquake 1 MellowFellow BOOK: Professional Android 2 Application Development 14 August 23rd, 2010 04:40 PM
Chapter 7 Part 2 Earthquake Exception clombardo BOOK: Professional Android 2 Application Development 3 April 29th, 2010 10:46 AM
Getting Exception after the Correction -for Chapter 6 Part 2 Earthquake project clombardo BOOK: Professional Android 2 Application Development 1 April 26th, 2010 06:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.