2013-08-12 29 views
6

Bu hata ile çok uğraştım ve pes ettim. GCM'yi kullanarak bir mesaj göndermeye her defasında LogCat'te bu hata görünür. Ne yapamadığım? GCM Bildirimleri'ni kurmak için Android örneklerini takip ettim. Bu LogCat Hatasıyayın hedefi iptal edildi. Android GCM

Düzenleme: İleti gerçekten gönderilir ama bu hatanın normal olduğunu düşünmüyorum.

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) } 

<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> 

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()); 

      } 
} 

cevap

6

Sabit Benim sınıf GCMBroadcastReceiver, sadece setResultCode (Activity.RESULT_OK) eklemeniz gerekir AndroidManifest.xml; onReceive() öğesinin sonunda; yöntem

İlgili konular