gpt4 book ai didi

Android - 触摸通知时提示对话框窗口

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:11:53 26 4
gpt4 key购买 nike

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

我的应用程序会提醒用户进行约会。到目前为止,我设法在约会日期的通知栏上显示提醒。

我的主管要求添加一项功能,即当用户在通知栏上点击时,将出现一个对话窗口并显示详细信息(约会的标题和地点)。

我如何实现这一目标?

最佳答案

试试这个:

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

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

假设 notif 是您的 Notification 对象:

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

如需其他帮助,您可以查看此 sample project ,它将帮助您:

关于Android - 触摸通知时提示对话框窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14100004/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com