p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Android 2 Application Development (http://p2p.wrox.com/forumdisplay.php?f=547)
-   -   Chapter 9 Earthquake 1 (http://p2p.wrox.com/showthread.php?t=80551)

MellowFellow August 17th, 2010 01:44 PM

Chapter 9 Earthquake 1
The Eclipse editor is telling me that it cannot resolve the Service.START_STICKY in the following code in the EarthquakeService Class:


  return Service.START_STICKY;
Any suggestions?

juniper August 17th, 2010 01:47 PM

Is your import correct?
import android.app.Service;

MellowFellow August 17th, 2010 01:55 PM

I have that in the import section yes:


import android.app.Service;
Any idea what else it could be?

juniper August 17th, 2010 02:25 PM

API Level?
What Android API Level are you using? Project Properties...Android...Project Build Target

START_STICKY was introduced at API Level 5

MellowFellow August 17th, 2010 02:40 PM

Thanks again. I was building in API Level 3. Its no longer giving me that problem.
When I run it now it gives the following error:

WARN/dalvikvm(499): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-17 14:00:47.341: ERROR/AndroidRuntime(499): FATAL EXCEPTION: main
08-17 14:00:47.341: ERROR/AndroidRuntime(499): java.lang.RuntimeException: Unable to start service com.paad.earthquake.EarthquakeService@43e6ccf0 with Intent { cmp=com.paad.earthquake/.EarthquakeService }: java.lang.ClassCastException: java.lang.String
08-17 14:00:47.341: ERROR/AndroidRuntime(499): at android.app.ActivityThread.handleServiceArgs(Activ ityThread.java:3063)

I'm using the code downloaded from this site.

juniper August 17th, 2010 03:31 PM

what JDK are you using?

MellowFellow August 17th, 2010 03:35 PM

JDK Version
I'm using JDK 1.6.0_20

juniper August 17th, 2010 04:10 PM

API Level
What API Level are you using now? It's working for me with 7 (2.1-update).

MellowFellow August 17th, 2010 04:27 PM

API Level
I'm using API level 7 as well now, but its not working. I'll have to copy the code again and re-try it. Thanks for the help.

MellowFellow August 18th, 2010 08:06 AM

Working File
I re-did it from scratch as a new project in API 7. It is now working!

All times are GMT -4. The time now is 06:25 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.