在IntentService创建吐司永远不会消失 [英] Toast created in an IntentService never goes away
本文介绍了在IntentService创建吐司永远不会消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个IntentService是下载一些文件。问题是,我创建IntentService内敬酒像这样
I have an IntentService that downloads some files. The problem is that I create a Toast inside the IntentService like this
Toast.makeText(getApplicationContext(), "some message", Toast.LENGTH_SHORT).show();
土司永远不会消失的事件,如果我退出程序。摧毁它的唯一方法是终止进程。
The Toast will never disappear event if I exit the app. The only way to destroy it is to kill the process.
我是什么做错了吗?
推荐答案
您不能创建吐司
- 从一个服务
。您应该使用 通知
来代替。
You shouldn't create Toast
s from a Service
. You should use a Notification
instead.
这篇关于在IntentService创建吐司永远不会消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文