android - 如何从android中的通知栏调用对话框?

标签 android notifications

我想从 android 中的通知栏调用 android 对话框而不是导致 url。这是我用来从通知调用 url 的代码。告诉我如何为对话框执行此操作。谢谢

notifyDetails.defaults |= Notification.DEFAULT_ALL;
Context context = getApplicationContext();
CharSequence contentTitle = "Notification Details...";
CharSequence contentText = "Browse Android Official Site by clicking me";
Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));

PendingIntent intent = 
                PendingIntent.getActivity(SimpleNotification.this, 0, 
                notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);

notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent);
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);

最佳答案

只需让 pendingintent 打开您的 Activity 之一,让您的 Activity 完全透明,然后打开一个对话框即可。

编辑 向 Intent 添加标志

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

关于android - 如何从android中的通知栏调用对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8146680/

相关文章:

java - 当用户开始输入时如何监听?

php - 使用密码保护表单时发送通知 - Wordpress

android - Zxing lib。不适用于 Android M 以上

android - 为什么 "appAuthRedirectScheme"作为 list 占位符无效?

android - 通过通知提示用户 - 需要向用户反馈吗?

callback - 钛移动推送通知回调未触发

php - 使用 jquery php 自动发送电子邮件通知

swift - 为什么只调用我的最后一个本地通知函数?

java - 在 Android 中映射 XML 属性和代码方法

android - 使用 Chrome 调试 Android 设备时如何在“网络”选项卡下跟踪 MobileFirst 7.1 服务器查询?