如何停止的AsyncTask线程的Andr​​oid? [英] How to stop asynctask thread in android?

查看:132
本文介绍了如何停止的AsyncTask线程的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想停止从另一个的AsyncTask 线程的AsyncTask 线程。我试图像 新AsyncTask.cancel(真)停止后台进程,但它并没有停止。

难道任何一个可以帮助我在这?

解决方案

 私人YourAsyncTask mTask;
 

声明你的AsyncTask在您的活动。

  mTask =新YourAsyncTask()执行()。
 

实例化这样说。

  mTask.cancel(真正的);
 

杀/取消这样的。

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?

解决方案

private YourAsyncTask mTask;

declare your asyncTask in your activity.

mTask = new YourAsyncTask().execute();

instantiate it like this.

mTask.cancel(true);

kill/cancel it like this.

这篇关于如何停止的AsyncTask线程的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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