Ich versuche, einen GCM-Client zu machen, Registrierung ist in Ordnung. Ich sende auch erfolgreich Nachrichten vom Server. Der Client startet die Absicht jedoch nicht. Es sagtGoogle Cloud-Messaging-Empfänger Absicht nicht gestartet (Broadcast Intent Callback: Ergebnis = CANCELLED forIntent)
09-30 08: 39: 59,795: W/GTalkService (4667): [DataMsgMgr] Broadcast Absicht Rückruf: Ergebnis = ABGESAGT forIntent {act = com.google.android.c2dm.intent.RECEIVE Katze = [dol.framework] (hat Extras)}
Meine Absicht
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);
}
}
Und mein Empfänger
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);
}
}
Und mein Manifest schließlich
<?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 für die Wand des Textes. Sowohl GCMService als auch GCMReceiver stehen ganz oben auf meinem Paket (dol.framework). Was mache ich falsch? Anders als diese mache ich nicht viel. Ich registriere nur das Gerät und sende dann eine Nachricht an dieses Gerät. Das Protokoll druckt die Nachricht oben aus, tut aber nichts. Sollte ich nicht den Dienst beginnen oder so? Ich habe nichts in Bezug auf Beispiele gesehen.
[In Verbindung stehender] (http://stackoverflow.com/questions/11902947/broadcast-intent-callback-result-cancelled-forintent) könnte helfen. – jedwards