在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.