gpt4 book ai didi

android - 来自通知 : AlertDialog without UI

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:19:05 25 4
gpt4 key购买 nike

我正在创建一个触发 Intent 的通知。这是我的代码的一个真正缩短的摘录......

Notification notification = new Notification(R.drawable.icon, "notification", System.currentTimeMillis());
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(BackgroundService.this, ConnectionHandler.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
notificationIntent.addFlags(Intent.FLAG_FROM_BACKGROUND);

PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, getString(R.string.notification_title), getString(R.string.notification_body), pendingIntent);
notification.flags |= notification.FLAG_AUTO_CANCEL;
nm.notify(1, notification);

在我的 Intent (ConnectionHandler.class) 中,我想显示一个有效的 AlertDialog。但我希望 AlertDialog 在不打开新的 UI 窗口的情况下出现。对我来说最好的是,如果 AlertDialog 在点击通知条目时只出现而没有其他任何内容。

任何想法都会受到赞赏。

问候,托比

最佳答案

来自Dev Guide :

Showing a Dialog

A dialog is always created and displayed as a part of an Activity.

简单的替代方法是创建一个非常基本的 Activity,除了对话框之外不显示任何内容,并在对话框关闭后立即调用 finish()

关于android - 来自通知 : AlertDialog without UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6023926/

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