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

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

问题描述

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



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



我的主管已经请求添加一个功能,当通知栏上的用户标签,将出现一个对话窗口并显示详细信息(约会的名称和位置)。



如何实现?

解决方案

尝试这样:

  Intent notifyIntent = new Intent上下文中,YourActivityClassHere.class); 
notifyIntent.setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);
// UNIQUE_ID如果您希望有多个通知出现
PendingIntent intent = PendingIntent.getActivity(SimpleNotification.this,UNIQUE_ID,
notifyIntent,PendingIntent.FLAG_UPDATE_CURRENT);

只需让 PendingIntent 打开您的一个活动,并让您的活动要完整透明,只需打开一个对话框。



编辑:如果要从通知点击事件中打开活动:



假设通知通知对象:

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

对于其他帮助,您可以查看此示例项目,它将帮助您:


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?

解决方案

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

just make the PendingIntent open up one of your Activities and have your Activity be complete transparent and just open a Dialog.

EDIT: 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:

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

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