java - Android - Unable to instantiate receiver -
i have problem when using broadcast. error occurs when using broadcastreceiver
.
here code:
<receiver android:name="com.org.ti.lucky.gcm.gcmbroadcastreceiver" android:permission="com.google.android.c2dm.permission.send" > <intent-filter> <!-- receives actual messages. --> <action android:name="com.google.android.c2dm.intent.receive" /> <category android:name="com.org.ti.lucky.gcm" /> </intent-filter> </receiver> <service android:name="com.org.ti.lucky.gcm.gcmintentservice" />
here class , error:
package com.org.ti.lucky.gcm; import android.app.activity; import android.content.componentname; import android.content.context; import android.content.intent; import android.support.v4.content.wakefulbroadcastreceiver; public class gcmbroadcastreceiver extends wakefulbroadcastreceiver { @override public void onreceive(context context, intent intent) { // explicitly specify gcmintentservice handle intent. componentname comp = new componentname(context.getpackagename(), gcmintentservice.class.getname()); // start service, keeping device awake while launching. startwakefulservice(context, (intent.setcomponent(comp))); setresultcode(activity.result_ok); } }
here logcat output:
04-09 14:38:09.899: e/androidruntime(2103): fatal exception: main 04-09 14:38:09.899: e/androidruntime(2103): java.lang.runtimeexception: unable instantiate receiver com.org.ti.lucky.gcm.gcmbroadcastreceiver: java.lang.classnotfoundexception: com.org.ti.lucky.gcm.gcmbroadcastreceiver 04-09 14:38:09.899: e/androidruntime(2103): @ android.app.activitythread.handlereceiver(activitythread.java:2210) 04-09 14:38:09.899: e/androidruntime(2103): @ android.app.activitythread.access$1500(activitythread.java:130) 04-09 14:38:09.899: e/androidruntime(2103): @ android.app.activitythread$h.handlemessage(activitythread.java:1271) 04-09 14:38:09.899: e/androidruntime(2103): @ android.os.handler.dispatchmessage(handler.java:99) 04-09 14:38:09.899: e/androidruntime(2103): @ android.os.looper.loop(looper.java:137) 04-09 14:38:09.899: e/androidruntime(2103): @ android.app.activitythread.main(activitythread.java:4745) 04-09 14:38:09.899: e/androidruntime(2103): @ java.lang.reflect.method.invokenative(native method) 04-09 14:38:09.899: e/androidruntime(2103): @ java.lang.reflect.method.invoke(method.java:511) 04-09 14:38:09.899: e/androidruntime(2103): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 04-09 14:38:09.899: e/androidruntime(2103): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 04-09 14:38:09.899: e/androidruntime(2103): @ dalvik.system.nativestart.main(native method) 04-09 14:38:09.899: e/androidruntime(2103): caused by: java.lang.classnotfoundexception: com.org.ti.lucky.gcm.gcmbroadcastreceiver 04-09 14:38:09.899: e/androidruntime(2103): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:61) 04-09 14:38:09.899: e/androidruntime(2103): @ java.lang.classloader.loadclass(classloader.java:501) 04-09 14:38:09.899: e/androidruntime(2103): @ java.lang.classloader.loadclass(classloader.java:461) 04-09 14:38:09.899: e/androidruntime(2103): @ android.app.activitythread.handlereceiver(activitythread.java:2205) 04-09 14:38:09.899: e/androidruntime(2103): ... 10 more