Register Gcm From A Library Project
I am trying to register to GCM from a library project the GCMIntentService is defined inside the library project. Here is my registration code(inside the library project): public s
Solution 1:
Here's what you have to do :
Write a class (in your library project) that overrides GCMBroadcastReceiver :
package com.test.pushlibrary;
import android.content.Context;
import com.google.android.gcm.GCMBroadcastReceiver;
publicclassPushLibraryBroadcastReceiverextendsGCMBroadcastReceiver
{
/**
* Gets the class name of the intent service that will handle GCM messages.
*/@Overrideprotected String getGCMIntentServiceClassName(Context context) {
return"com.test.pushlibrary.GCMIntentService";
}
}
Change your manifest to refer to the new receiver :
<receiver
android:name="com.test.pushlibrary.PushLibraryBroadcastReceiver"
...
The reason that your original code didn't work is that the default implementation of getGCMIntentServiceClassName
assumes that the intent service class is located in the package of the application, so it's expecting com.example.pushtest.GCMIntentService
instead of com.test.pushlibrary.GCMIntentService
.
Post a Comment for "Register Gcm From A Library Project"