Hi,
I download code example from wrox site and import Chapter 9 Earthquake (2, 3, 4 all same result) and do
1. set Build target to Google APIs (Android 2.1)
2. change EarthquakeProvider.java
" + KEY_MAGNITUDE + " FLOAT), "
to
" + KEY_MAGNITUDE + " FLOAT, "
3. run -> Debug
4. result is Earthquake not response and force close.
5. logcat error show
Code:
12-07 10:14:44.607: E/AndroidRuntime(209): Uncaught handler: thread main exiting due to uncaught exception
12-07 10:14:44.737: E/AndroidRuntime(209): java.lang.RuntimeException: Unable to start service com.paad.earthquake.EarthquakeService@43baf6d0 with Intent { cmp=com.paad.earthquake/.EarthquakeService }: java.lang.ClassCastException: java.lang.String
12-07 10:14:44.737: E/AndroidRuntime(209): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2882)
12-07 10:14:44.737: E/AndroidRuntime(209): at android.app.ActivityThread.access$3500(ActivityThread.java:119)
12-07 10:14:44.737: E/AndroidRuntime(209): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
12-07 10:14:44.737: E/AndroidRuntime(209): at android.os.Handler.dispatchMessage(Handler.java:99)
12-07 10:14:44.737: E/AndroidRuntime(209): at android.os.Looper.loop(Looper.java:123)
12-07 10:14:44.737: E/AndroidRuntime(209): at android.app.ActivityThread.main(ActivityThread.java:4363)
12-07 10:14:44.737: E/AndroidRuntime(209): at java.lang.reflect.Method.invokeNative(Native Method)
12-07 10:14:44.737: E/AndroidRuntime(209): at java.lang.reflect.Method.invoke(Method.java:521)
12-07 10:14:44.737: E/AndroidRuntime(209): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-07 10:14:44.737: E/AndroidRuntime(209): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-07 10:14:44.737: E/AndroidRuntime(209): at dalvik.system.NativeStart.main(Native Method)
12-07 10:14:44.737: E/AndroidRuntime(209): Caused by: java.lang.ClassCastException: java.lang.String
12-07 10:14:44.737: E/AndroidRuntime(209): at android.app.ApplicationContext$SharedPreferencesImpl.getInt(ApplicationContext.java:2579)
12-07 10:14:44.737: E/AndroidRuntime(209): at com.paad.earthquake.EarthquakeService.onStartCommand(EarthquakeService.java:50)
12-07 10:14:44.737: E/AndroidRuntime(209): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2873)
12-07 10:14:44.737: E/AndroidRuntime(209): ... 10 more
After modify "+ KEY_MAGNITUDE + " FLOAT), " to + "KEY_MAGNITUDE + " FLOAT, " Chapter 8 program running OK but Chapter 9 (all version, chapter 10 etc.) still have problem.
Could you check and update?
By the way code example for Android 4 book is OK. But for Android 2 I can not get it run.
Thank you,
Lin2012