Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

broadcast intent cancelled. Android GCM

I've been struggling with this error for a lot and I just gave up. Every time I try to send a message using GCM this error appears on LogCat. What I'm failing to do? I've followed Android examples to set up GCM Notifications. This is the LogCat Error

Edit: The message actually gets through but I don't think this error is normal.

08-12 17:13:15.888: W/GTalkService(2237): [DataMsgMgr] broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.testing.encuesta] (has extras) }

AndroidManifest.xml

<permission android:name="com.testing.encuesta.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.testing.encuesta.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>


<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.testing.encuesta.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>
    <activity android:name=".Inicio">
    </activity>

         <receiver android:name=".GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
    <intent-filter>

          <action android:name="com.google.android.c2dm.intent.RECEIVE" />
          <category android:name="com.testing.encuesta" />
      </intent-filter>
      <intent-filter>
          <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
          <category android:name="com.testing.encuesta" />
      </intent-filter>

    </receiver>

My class GCMBroadcastReceiver

public class GCMBroadcastReceiver extends BroadcastReceiver  {

@Override
public void onReceive(Context context, Intent intent) {
            try {
                String action=intent.getAction();
                if(action.equals("com.google.android.c2dm.intent.REGISTRATION"))
                {
                    String registrationID=intent.getStringExtra("registration_id");
                    Log.d("ID",registrationID);
                    String error=intent.getStringExtra("error");
                    String unregistered=intent.getStringExtra("unregistered");

                }
                else if(action.equals("com.google.android.c2dm.intent.RECEIVE"))
                {
                    String data1=intent.getStringExtra("data1");
                    String data2=intent.getStringExtra("data2");
                    Toast.makeText(context, data1, Toast.LENGTH_LONG);

                }
            } catch (Exception e) {
                Log.d("Error", "error en C2DM"+e.toString());

            }
}
like image 209
Cristian Eduardo Lehuede Lyon Avatar asked Aug 12 '13 21:08

Cristian Eduardo Lehuede Lyon


1 Answers

Fixed, you just need to add setResultCode(Activity.RESULT_OK); at the end of the onReceive(); method

like image 198
Cristian Eduardo Lehuede Lyon Avatar answered Sep 22 '22 16:09

Cristian Eduardo Lehuede Lyon