如何在android中停止异步任务线程? [英] How to stop asynctask thread in android?
本文介绍了如何在android中停止异步任务线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从另一个 AsyncTask
线程停止一个 AsyncTask
线程.我试过像new AsyncTask.cancel(true)
停止后台进程,但它没有停止.
有人能帮我解决这个问题吗?
解决方案
在您的活动中声明您的 asyncTask:
private YourAsyncTask mTask;
像这样实例化它:
<块引用>mTask = new YourAsyncTask().execute();
像这样杀死/取消它:
<块引用>mTask.cancel(true);
I want to stop a AsyncTask
thread from another AsyncTask
thread. I have tried like
new AsyncTask.cancel(true)
to stop the background process but it didn't stop.
Could any one help me on this?
解决方案
declare your asyncTask in your activity:
private YourAsyncTask mTask;
instantiate it like this:
mTask = new YourAsyncTask().execute();
kill/cancel it like this:
mTask.cancel(true);
这篇关于如何在android中停止异步任务线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文