Android - Prompt Dialog window when touch on Notification

前端 未结 1 1197
时光说笑
时光说笑 2021-01-03 09:20

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 mana

相关标签:
1条回答
  • 2021-01-03 10:02

    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:

    0 讨论(0)
提交回复
热议问题