Question

I already on a GCM project which is able to receive and message from Google Server after Registration.

This project contains only one package (com.example.gcm), and all classes (GCMIntentService ...) are declared in this package. The code below describs my Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="YOUR PACKAGE NAME"
android:versionCode="1"
android:versionName="1.0" >
....
<receiver
        android:name="com.google.android.gcm.GCMBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="YOUR PACKAGE NAME" />
        </intent-filter>
    </receiver>

    <service android:name=".GCMIntentService" />

Now I'm trying to integrate this GCM project on my main project which contains at least 4 sub packages. I adopt the same configuration of the Manfiest and I got something like that

 ....
<receiver
        android:name="com.google.android.gcm.GCMBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="YOUR PACKAGE NAME" />
        </intent-filter>
    </receiver>

    <service android:name=".notification.GCMIntentService" />

In the logcat, I got GCM IntentService class: YOUR PACKAGE NAME.GCMIntentService which isn't correct because the class is in a sub package.

If I change the name of the service and i put the full name of the package I got this:

Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTRATION cat=[ xxx ] flg=0x10 cmp=xxxx (has extras) }: not found

I already read a lot of thread but nothing helpful.

Is there a way to figure this out?

Was it helpful?

OTHER TIPS

You should define your own Receiver class, Then add it to your AndroidManifest.xml

public class GCMReceiver extends GCMBroadcastReceiver { 
    @Override
    protected String getGCMIntentServiceClassName(Context context) { 
        return "com.example.gcm.GCMService"; 
    } 
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top