Activity as Broadcast receiver

In this post I show how to instantiate a broadcast receiver in an activity. An example for which this kind of broadcast receiver is useful is when calling the GCM library service to register/unregister from the GCM servers. When the service asynchronously receives the response from GCM servers, if the …

GCM sender id not set on constructor solution

In an Android application that imports the Google Cloud Messaging library to receive messages from its server, it is possible to get the following exception: FATAL EXCEPTION: IntentService[GCMIntentService-DynamicSenderIds-3] java.lang.IllegalStateException: sender id not set on constructor at com.google.android.gcm.GCMBaseIntentService.getSenderIds (GCMBaseIntentService.java:125) at com.google.android.gcm.GCMBaseIntentService.onHandleIntent (GCMBaseIntentService.java:237) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.os.HandlerThread.run(HandlerThread.java:60)   …