gpt4 book ai didi

java - 来自后台线程的 PopUp 对话框 Android

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:23:51 24 4
gpt4 key购买 nike

当我从不同线程收到消息时,我需要显示一个弹出对话框,但该对话框不应依赖于 Activity,即它应该在屏幕焦点所在的任何位置显示该对话框。

可以吗?因为对话框是按 Activity 处理的,所以我考虑过使用服务,但又会添加一个线程,我想避免这种情况。

还有其他选择吗?

最佳答案

如果您试图询问当您的 Activity 不是用户手机上的焦点 Activity 时如何显示对话框,请尝试改用通知。当用户正在做其他事情时,在不同的应用程序上弹出一个对话框会打断他们。来自Android UI guidelines :

Use the notification system — don't use dialog boxes in place of notifications

If your background service needs to notify a user, use the standard notification system — don't use a dialog or toast to notify them. A dialog or toast would immediately take focus and interrupt the user, taking focus away from what they were doing: the user could be in the middle of typing text the moment the dialog appears and could accidentally act on the dialog. Users are used to dealing with notifications and can pull down the notification shade at their convenience to respond to your message.

创建通知的指南在这里:http://developer.android.com/guide/topics/ui/notifiers/notifications.html

关于java - 来自后台线程的 PopUp 对话框 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1027149/

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