即使应用已关闭,Android显示Toast [英] Android display Toast even the app is closed

查看:90
本文介绍了即使应用已关闭,Android显示Toast的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说,我必须计算两位数的总和,然后将这两个值传递给服务器,服务器将返回计算出的值,然后应用程序将其显示在 Toast 中.它完美地工作.但是,即使该应用程序已关闭,我也想显示此 Toast .我想知道是否可以使用任何其他 Context 来创建全局的 Toast .还是最好的方法是什么?创建 Notification 是否有意义?

Say, I have to calculate the sum of two digits and I pass the two values to the server and sever returns the calculated value and the app displays it in a Toast. It works perfectly. But I want to show this Toast even though the app is closed. I am wondering if I could use any other Context to make a global Toast. or what is the best way? Do creating a Notification makes any sense?

推荐答案

即使您的应用程序不在前台也要显示敬酒不是最好的主意.这是因为 Toast 突然冒出来可能很烦人,毫无根据,并破坏了用户当前正在执行的操作.

Showing toasts when your application isn't in the foreground even if possible is not the best idea. This is because a Toast poppoing out of nowhere can be annoying, uninformative and disrupt whatever the user is currently doing.

正如您提到的,通知是进行此操作的方法.只要用户决定执行通知,便可以读取该通知,并且与Toast simple相比,它不会被遗漏,因为检查通知需要用户采取行动.

As you mentioned, Notifications are the way to go on this one. A notification can be read by the user whenever he decides to do it and they can't be missed as opposed to Toast simple because checking the notification requires the user to take action.

您可以阅读有关通知以及如何实施通知的更多信息此处 .

You can read more on notifications and how to implement them HERE.

这篇关于即使应用已关闭,Android显示Toast的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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