4

I am new to android application development. I am doing an application for my final year project.

My application will remind a user for an appointment. So far I manage to show the alert on notification bar on the appointment date.

My supervisor has requested to add a function, that, when a user tab on the notification bar, there will be a dialog window and show the details (Title of the appointment and the location).

How do I achieve this?

Pranav 웃
  • 8,469
  • 6
  • 38
  • 48
user1939393
  • 91
  • 1
  • 5

1 Answers1

5

Try this:

Intent notifyIntent = new Intent(context,YourActivityClassHere.class);
notifyIntent.setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);
//UNIQUE_ID if you expect more than one notification to appear
PendingIntent intent = PendingIntent.getActivity(SimpleNotification.this, UNIQUE_ID, 
            notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  1. Make the PendingIntent open up one of your Activities
  2. Make that Activity completely transparent and open a Dialog.

IF you want to open an Activity from notification click event:

Assuming that notif is your Notification object:

Intent notificationIntent = new Intent(this.getApplicationContext(), ActivityToStart.class);
PendingIntent contentIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, notificationIntent, 0);
notif.contentIntent = contentIntent;

For other assistance you can view this sample project, it will help you:

Peter
  • 437
  • 1
  • 4
  • 20
Sam-In-TechValens
  • 2,501
  • 4
  • 34
  • 67