Call Activity open via Notification without losing information

0

I'm having trouble calling an Activit through Notification, every time I press the notification the Activity loads from scratch, losing the data that was in the one that was open.

        NotificationManagerCompat nm = NotificationManagerCompat.from(context);

    Intent it = new Intent(context, MapsActivity.class);

    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(context)
                    .setDefaults(Notification.DEFAULT_ALL)
                    .setAutoCancel(true)

                    .setContentIntent(PendingIntent.getActivity(context, 0, it, PendingIntent.FLAG_UPDATE_CURRENT))
                    .setSmallIcon(R.mipmap.ic_usuario)
                    .setContentTitle("Aplicativo")
                    .setContentText(msg)
                    .setAutoCancel(true).setDefaults(2).setDefaults(1)
                    .setSound(RingtoneManager.getDefaultUri(2), 3);

    nm.notify(1, mBuilder.build());

I just want the notification to call the Activity that is open, vlw!

    
asked by anonymous 19.05.2016 / 14:44

1 answer

1

You are probably creating another activity, test put to the activity in your manifest:

android:launchMode="singleTask"

Another problem might be that you are cleaning the data in OnStart() or OnResume() .

    
19.05.2016 / 16:09