加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 从后台线程的PopUp对话框Android

发布时间:2020-12-14 05:24:52 所属栏目:Java 来源:网络整理
导读:我需要一个弹出对话框,当我收到来自不同线程的消息时,该对话框不应该依赖于活动,即应该在屏幕焦点位置显示对话框. 可以做吗因为每个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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读