Android - 触摸通知时提示对话框窗口 [英] Android - Prompt Dialog window when touch on Notification

查看:15
本文介绍了Android - 触摸通知时提示对话框窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Android 应用程序开发的新手.我正在为我的最后一年项目申请.

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).

我如何实现这一目标?

推荐答案

试试这个:

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. 使 PendingIntent 打开您的一项活动
  2. 使该活动完全透明并打开一个对话框.

如果你想从通知点击事件中打开一个活动:

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

假设 notif 是您的 Notification 对象:

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:

这篇关于Android - 触摸通知时提示对话框窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆