不幸的是应用程序已停止通知发送错误

Unfortunately app has stopped error in notification sending

import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

import com.google.android.gms.gcm.GcmListenerService;
import com.htl.jsfshoppingfestival.DataBaseHandler;

public class MyGcmListenerService extends GcmListenerService {

    private static final String TAG = "MyGcmListenerService";
    private NotificationManager mNotificationManager;
    Context ctx;
    int countNotification=0;

    public void onMessageReceived(String from, Bundle data) {
        String message = data.getString("Message");
        Log.d(TAG, "From: " + from);
        Log.d(TAG, "Message: " + message);

      //  Toast.makeText(getApplicationContext(), "Notification :"+message, Toast.LENGTH_LONG).show();

      //  Toast.makeText(getApplicationContext(),from+message,Toast.LENGTH_LONG).show();    

        if (from.startsWith("/topics/")) {
            // message received from some topic.
        } else {
            // normal downstream message.
        }

        // [START_EXCLUDE]
        /**
         * Production applications would usually process the message here.
         * Eg: - Syncing with server.
         *     - Store message in local database.
         *     - Update UI.
         */

        /**
         * In some cases it may be useful to show a notification indicating to the user
         * that a message was received.
         */
        sendNotification(message);

        // [END_EXCLUDE]
    }
    // [END receive_message]

    /**
     * Create and show a simple notification containing the received GCM message.
     *
     * @param message GCM message received.
     */
    private void sendNotification(String message) {

        DataBaseHandler db = new DataBaseHandler(this);
        db.addMessage(message);
        countNotification=db.getRowCount();
        db.close();

        Log.d("sender", "Broadcasting message");
        Intent localIntent = new Intent("badge count");
        // You can also include some extra data.
        localIntent.putExtra("Count", countNotification);
        LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);
}
}    

发送通知时我没有收到通知消息,我的应用程序显示:

Unfortunately app has stopped

在调试中我得到了 message=null 并且应用程序给出了错误。

您需要检查消息不等于null。

if(message != null && !message.trim().isEmpty())
{
     sendNotification(message);
}

你在哪个区块得到了null? OnMessageReceived 或 SendNotification?