I'm getting the following message in the logcat when I try to call
startService (for an IntentService)  inside a BroadcastReceiver:

02-03 15:50:02.944: E/AndroidRuntime(530): FATAL EXCEPTION: main
02-03 15:50:02.944: E/AndroidRuntime(530): java.lang.RuntimeException:
Unable to instantiate service com.sensor2cloud.raisin.DataqService:
java.lang.InstantiationException: com.sensor2cloud.raisin.DataqService
02-03 15:50:02.944: E/AndroidRuntime(530):      at
android.app.ActivityThread.handleCreateService(ActivityThread.java:
1929)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
android.app.ActivityThread.access$2500(ActivityThread.java:117)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:985)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
android.os.Handler.dispatchMessage(Handler.java:99)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
android.os.Looper.loop(Looper.java:123)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
android.app.ActivityThread.main(ActivityThread.java:3683)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
java.lang.reflect.Method.invokeNative(Native Method)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
java.lang.reflect.Method.invoke(Method.java:507)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
dalvik.system.NativeStart.main(Native Method)
02-03 15:50:02.944: E/AndroidRuntime(530): Caused by:
java.lang.InstantiationException: com.sensor2cloud.raisin.DataqService
02-03 15:50:02.944: E/AndroidRuntime(530):      at
java.lang.Class.newInstanceImpl(Native Method)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
java.lang.Class.newInstance(Class.java:1409)
02-03 15:50:02.944: E/AndroidRuntime(530):      at
android.app.ActivityThread.handleCreateService(ActivityThread.java:
1926)

My BR onReceive code looks like this:

public class DataqAlarmReceiver extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
                context.startService( new Intent( context , DataqService.class 
) );
        }

}

My manifest service/receiver section looks like this:

        <service android:name="com.sensor2cloud.raisin.DataqService">
        </service>
        <receiver
android:name="com.sensor2cloud.raisin.DataqAlarmReceiver">
                        <intent-filter>
                                <action 
android:name="android.intent.action.BOOT_COMPLETED"/>
                        </intent-filter>
        </receiver>

The constructor of my IntentService looks like this:

        public DataqService(String name) {
                super("DataqService");
        }

>From the debugger, I can see the constructor is never getting called.

I'm guessing that the context I'm passing in onReceive is not an
appropriate one for the IntentService. Any ideas about what might be
wrong?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to