Java 广播接收器无法接收谷歌云消息

Java 广播接收器无法接收谷歌云消息,java,android,google-cloud-messaging,Java,Android,Google Cloud Messaging,我已经学习谷歌云消息API好几天了,现在,我的应用程序出现了一个错误。 首先,我用php构建了我的服务器,它返回关于GCM的成功消息,如下所示: {"multicast_id":7148194663931263470,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1413222862155080%099070adf9fd7ecd"}]} 但是在我的应用程序中,我尝试了许多方法来确保我的应用程序将收到消

我已经学习谷歌云消息API好几天了,现在,我的应用程序出现了一个错误。 首先,我用php构建了我的服务器,它返回关于GCM的成功消息,如下所示:

{"multicast_id":7148194663931263470,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1413222862155080%099070adf9fd7ecd"}]}
但是在我的应用程序中,我尝试了许多方法来确保我的应用程序将收到消息。但我失败了。我的申请没有收到任何东西

有人帮我。以下是Manifest.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.dangchienhsgs.giffus" >

    <permission
        android:name="com.dangchienhsgs.giffus.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.dangchienhsgs.giffus.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".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=".HomeActivity"
            android:label="@string/title_activity_home" >
        </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.dangchienhsgs.giffus" />
            </intent-filter>
        </receiver>

        <provider
            android:name=".provider.DataProvider"
            android:authorities="com.dangchienhsgs.giffus.provider"
            android:exported="false" >
        </provider>

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

        <activity
            android:name=".RegisterActivity"
            android:label="@string/title_activity_register" >
        </activity>

        <!--<service android:name=".account.AuthenticatorService" >
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator" />
            </intent-filter>

            <meta-data
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/authenticator" />
        </service> -->

    </application>

</manifest>

这是我的Github链接:“

我检查了您的代码以接收消息,它似乎还可以


您是否将设备注册到GCM上:

是的,我注册了。这是我的github链接:你能帮我检查一下吗?我正在努力使用Google API,因为我希望我的应用程序可以通过用户名和密码登录。我让它在用户每次登录他的帐户时注册一个注册ID。我还将其更新到我的服务器。有什么问题吗?我读了你的代码,一切似乎都很好。如果服务器得到正确的(最后一个)ID,在每次登录中注册ID应该不会有问题。我认为,在Android中一切都正常。因此,您可以尝试在没有服务器的情况下调试它。我用。尝试获取注册id并在此程序中创建POST请求。以下是请求文件:
package com.dangchienhsgs.giffus;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.util.Log;
import android.widget.Toast;

import com.google.android.gms.gcm.GoogleCloudMessaging;

public class GCMBroadcastReceiver extends WakefulBroadcastReceiver {
    private static final String TAG="GCMBroadcastReceiver";
    @Override
    public void onReceive(Context context, Intent intent) {
        // Sure that GCMIntentService will handle the intent
        Log.d(TAG, "is Received");
        Log.d(TAG, "Our message is received");
        ComponentName comp=new ComponentName(context.getPackageName(),
                GcmIntentService.class.getName());
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);
    }


}