I am actually working with notifications
in Android.
To do my application test, I follow the guide on android.developer .
I create my notification, it works well. When I click on it, it removes the notification from the notification tab and after I go to my Activity.
Here is the code I use to do that :
public void createSimpleNotification() {
NotificationCompat.Builder mNotifBuilder = new NotificationCompat.Builder(this.getApplicationContext())
.setSmallIcon(R.drawable.ic_notif).setContentTitle("Simple notif").setContentText("Welcome on our app, click here");
Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder mStackBuilder = TaskStackBuilder.create(this.getApplicationContext());
mStackBuilder.addParentStack(MainActivity.class);
mStackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = mStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
mNotifBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotifManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotifManager.notify(0, mNotifBuilder.build());
}
I only have my MainActivity
and a Button
. When I click on the button, the notification appears and I click on notification, i come back to my MainActivity.
Here is my problem :
I want to update my MainActivity UI
after clicking on the notification. After clicking on notification, I need to create a Dialog
who shows the text of the notification.
How can I modify my Activity
and add new View
after clicking on a notification?