Google cloud messaging receiver intent does not start (broadcast intent callback: result=CANCELLED forIntent)

11,201

In the permission you defined and used for GCM you have dol.framework.gcm.permission. It should be dol.framework.permission, since your app's package is dol.framework.

Share:
11,201

Related videos on Youtube

Cœur
Author by

Cœur

Everybody should contribute to clean up Stack Overflow. SO is intended to be a top-quality Q&A site, meant not just for the OP, but for posterity. Thanks to search engines, questions and answers become authoritative for the whole Internet. --Paul Draper TODO: disambiguate the 18,300+ duplicate titles from 41,600+ questions fix the uneditable titles (1,117 titles with length < 15) fix the uneditable titles (containing "help", "problem", "question", "doubt", …) fix the uneditable messages (containing "mydomain.com", "domain.com", "mysite.com", "site.com", "abc.com", "xyz.com", …) fix the uneditable messages with link shorteners (5,032 url:goo.gl, 3,673 url:bit.ly, 1,982 url:tinyurl.com, 1,748 url:cl.ly, …) remove the dead images/codes (8,051 url:imageshack.us, 2,818 url:pastie.org, 2,307 url:photobucket, 430 url:skitch.com, 214 url:rapidshare.com, 78 url:paste.ofcode.org, 58 url:expirebox.com, 4 url:megaupload.com, …) fix the broken links in messages, broken links to connect.microsoft.com, … review the potentially broken Apple links: #DOCUMENTATION in the URL, /library but not /archive in the URL, url:developer.apple.com/mac/library, url:developer.apple.com/safari/library rollback the 99+ solved, resolved, fixed, answered titles (meta, alternative query) correct the spelling in titles correct the 6,600+ "thanks in advanced" and 1,100+ "thanks in advice", …

Updated on July 04, 2022

Comments

  • Cœur
    Cœur almost 2 years

    I am trying to make a GCM client, registration is fine. I am also successfully sending messages from server. However, the client does not start the intent. It says

    09-30 08:39:59.795: W/GTalkService(4667): [DataMsgMgr] broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE cat=[dol.framework] (has extras) }

    My Intent

    public class GCMService extends IntentService{
    
        public GCMService(String name) {
            super("GCMService");
        }
    
        protected void onHandleIntent(Intent intent) {
            Bundle extras = intent.getExtras();
            String messageType = gcm.getMessageType(intent);
            android.util.Log.i("hi","test");
            if (!extras.isEmpty()) {
    
                if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
                    Logger.logInUI(tag, "Received: " + extras.toString());
                }
            }
            GCMReceiver.completeWakefulIntent(intent);
        }
    }
    

    And my receiver

    public class GCMReceiver extends WakefulBroadcastReceiver {
        public void onReceive(Context context, Intent intent) {
            ComponentName comp = new ComponentName(context.getPackageName(),
                    GCMService.class.getName());
            startWakefulService(context, (intent.setComponent(comp)));
            Logger.log("hi","eetett");
            setResultCode(Activity.RESULT_OK);
        }
    }
    

    And finally my manifest

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="dol.framework"
        android:versionCode="1"
        android:versionName="1.0" >
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.GET_ACCOUNTS" />
        <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    
        <uses-permission android:name="android.permission.WAKE_LOCK" />
    
        <permission android:name="dol.framework.gcm.permission.C2D_MESSAGE"
            android:protectionLevel="signature" />
        <uses-permission android:name="dol.framework.gcm.permission.C2D_MESSAGE" />
    
    
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="18" />
    
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:name="dol.framework.widget.DolApplication"
            android:label="Dol Framework"
            android:theme="@style/AppTheme" >
            <activity
                android:name="dol.framework.activity.DebugActivity"
                android:configChanges="orientation|keyboardHidden|screenSize"
                android:label="@string/app_name"
                android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <receiver
                android:name="dol.framework.GCMReceiver"
                android:permission="com.google.android.c2dm.permission.SEND" >
                <intent-filter>
                    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                    <category android:name="dol.framework" />
                </intent-filter>
            </receiver>
    
            <service android:name="dol.framework.GCMService"/>
        </application>
    
    </manifest>
    

    Sorry for the wall of text. Both GCMService and GCMReceiver is at top of my package (dol.framework). What am I doing wrong? Other than those, I am not doing much. Only registering the device and then I am sending a message to this device. Log prints the message at top but does nothing. Shouldn't I start service or something? I didn't see anything related on examples.

  • jedwards
    jedwards over 10 years
    Just a note, I'm using GCM (not C2DM), and don't need the REGISTRATION intent (I also think it should be REGISTER, not REGISTRATION)
  • dlee
    dlee over 10 years
    Me too! The app I'm working on at the moment with that code in the manifest is working. Do you have the right library set up (ie. not the old one)?
  • Admin
    Admin over 10 years
    Thank you very much! It worked after that (I actually saw something related to permissions in logs but disregarded that, damn cost me hours)