Popback对话框Android从后台线程 [英] PopUp dialog Android from background thread

查看:122
本文介绍了Popback对话框Android从后台线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need a popup dialog to be shown when i get a message from different thread but the dialog should be not dependent on Activity i.e, it should display the dialog wherever the screen focus is.

可以做吗?因为每个Activity都处理了对话框,所以我想到了使用一个服务,但是再次添加一个线程,我想避免这种情况。

Can it be done? Because the dialog is handled per Activity, I thought of using a service but again it would be one more thread added and I want to avoid that.

任何其他选项可用?

推荐答案

当您的活动不是用户手机上的重点活动,然后尝试使用通知时,询问如何显示对话框。通过不同的应用程序弹出对话框可能会在用户执行其他操作时中断用户。从 Android UI指南

If you're trying to ask how to show a dialog when your activity is not the focused activity on the user's phone then try using Notifications instead. Popping up a dialog over a different application interrupts the user when they may be doing something else. From the Android UI guidelines:


使用通知系统 - 不要
使用对话框代替
通知

如果您的后台服务需要
通知用户,请使用标准的
通知系统 - 不要使用
对话框或吐司来通知他们。 A
对话或吐司将立即采取
焦点并中断用户,将
重点放在他们所做的工作上:
用户可能在
的中间当对话框
出现并且可能会意外地对
对话时,键入文本。用户习惯于通过
处理通知,并且可以以
的方式将
下拉到通知栏,以便回复您的
消息。

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

A guide to create notifications is here: http://developer.android.com/guide/topics/ui/notifiers/notifications.html

这篇关于Popback对话框Android从后台线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆