来自通知:没有UI的AlertDialog

Atm*_*ons 7 user-interface notifications android android-intent

我正在创建一个触发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);
Run Code Online (Sandbox Code Playgroud)

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

任何想法都表示赞赏.

此致,托比

Ale*_*dam 8

来自开发指南:

显示对话框

始终会创建一个对话框,并将其显示为活动的一部分.

简单的替代方法是创建一个非常基本的Activity,除了对话框之外没有任何显示,并finish()在对话框被解除后立即调用.


paw*_*eba 5

创建透明活动,如下所示:

如何在Android上创建透明活动?

并将其与对话框主题相结合.