Error showing Arraylist items on android

0

I am sending through an intent an arraylist, it is filled as new messages arrive and I show them in a notification, when clicked the notification must be shown in a new view all the items This is my code:

private Emitter.Listener recibir_mensajes = new Emitter.Listener(){
        @Override
        public void call(Object... args) {
            JSONObject data = (JSONObject) args[0];
            try {
                id_modal = 2;
                a = data.getString("a");
                b = data.getString("b");
                c = data.getString("c");
                datos_mensajes_estudiante = new Datos_mensajes_estudiante(a,b,c);
                arrayList.add(datos_mensajes_estudiante);
                Log.d("PPPPPP",""+arrayList.size());
                if(!MapsActivity.validar_not_MapsActivity && !Todos_mensajes.validar_not_Todos_mensajes){
                    mostrar_notificacion();
                }
            } catch (JSONException e) {
                // return;
            }
        }
    };


private void mostrar_notificacion(){
        Intent notificacion = new Intent(this,Todos_mensajes.class);
        notificacion.putExtra("id_modal",id_modal);
        notificacion.putParcelableArrayListExtra( "arraylist", arrayList);
        PendingIntent pendingIntent = PendingIntent.getActivity(this,0,notificacion,PendingIntent.FLAG_ONE_SHOT);

        Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        Builder builder = new Builder(this);
        builder.setAutoCancel(true);
        builder.setContentTitle("Alerta");
        builder.setContentText("sms nuevo");
        builder.setSound(ringtone);
        builder.setSmallIcon(R.mipmap.icono);
        builder.setTicker("Nuevo mensaje ");
        builder.setLights(Color.GREEN, 1, 1);
        builder.setContentIntent(pendingIntent);

        NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0,builder.build());
    }

This when receiving in my view All_messages only shows me the last item and not all but I fill the arraylist in the following way:

arrayList.add(new Datos_mensajes_estudiante("a","B","C"));
                arrayList.add(new Datos_mensajes_estudiante("a","B","C"));
                arrayList.add(new Datos_mensajes_estudiante("a","B","C"));
                arrayList.add(new Datos_mensajes_estudiante("a","B","C"));

if all the items arrive.

How can I solve this?

    
asked by Dimoreno 20.05.2017 в 01:27
source

0 answers