package org.jboss.aerogear.unifiedpush.helloworld.activities;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import org.jboss.aerogear.android.unifiedpush.MessageHandler;
import org.jboss.aerogear.android.unifiedpush.Registrations;
import org.jboss.aerogear.unifiedpush.helloworld.HelloWorldApplication;
import org.jboss.aerogear.unifiedpush.helloworld.R;
import org.jboss.aerogear.unifiedpush.helloworld.handler.NotificationBarMessageHandler;

import java.util.ArrayList;
import java.util.List;

public class MessagesActivity extends Activity implements MessageHandler{

    private HelloWorldApplication application;
    private ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.messages);

        application = (HelloWorldApplication) getApplication();

        listView = (ListView) findViewById(R.id.messages);
    }

    @Override
    protected void onResume() {
        super.onResume();
        Registrations.registerMainThreadHandler(this);
        Registrations.unregisterBackgroundThreadHandler(NotificationBarMessageHandler.instance);

        displayMessages();
    }

    @Override
    protected void onStop() {
        super.onStop();
        Registrations.unregisterMainThreadHandler(this);
        Registrations.registerBackgroundThreadHandler(NotificationBarMessageHandler.instance);
    }

    @Override
    public void onMessage(Context context, Bundle message) {
        String alert = message.getString("alert");
        addNewMessage(alert);
    }

    @Override
    public void onDeleteMessage(Context context, Bundle message) {
    }

    @Override
    public void onError() {
    }

    private void addNewMessage(String alert) {
        application.addMessage(alert);
        displayMessages();
    }

    private void displayMessages() {
        ArrayAdapter<String> adapter = new ArrayAdapter<>(getApplicationContext(),
                R.layout.message_item, application.getMessages());
        listView.setAdapter(adapter);
    }

}

@@ -1035,16 +1035,125 @@
 ssages);
+%0A%0A        if(getIntent().getExtras() != null) %7B%0A            addNewMessage(getIntent().getExtras());%0A        %7D
 %0A    %7D%0A%0A
@@ -1717,59 +1717,8 @@
 ) %7B%0A
-        String alert = message.getString(%22alert%22);%0A
     
@@ -1731,29 +1731,31 @@
 dNewMessage(
-alert
+message
 );%0A    %7D%0A%0A  
@@ -1924,20 +1924,22 @@
 age(
-String alert
+Bundle message
 ) %7B%0A
@@ -1973,13 +1973,34 @@
 age(
+message.getString(%22
 alert
+%22)
 );%0A 

Add in the list, message received in notification bar