如何使用Volley库Android执行简单的异步任务 [英] How to do a simple async task using volley library android

查看:55
本文介绍了如何使用Volley库Android执行简单的异步任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道Google宣布了一个新的Volley库来管理基于HTTP协议的网络请求.

As you know Google has announced a new library Volley to manage network request based on HTTP Protocol.

但是如果我想使用该库连接到msql db.目前,我正在使用异步任务进行网络通话.

But if i want to use this library to connect to msql db . Currently i am using async task to do my network calls .

如何实现凌空库做异步任务?任何链接或示例.对不起,英语不好:)

How to implement volley library to do async task ? any links or example . sorry for bad english :)

推荐答案

Volley自行启动后台线程,因此所有网络请求均在UI线程之外执行,因此基本上您不再需要使用AsyncTask .当然,在轮换或用户退出活动时,您必须小心取消正在运行的请求.

Volley is starting background thread(s) on its own so all the network requests are executed off the UI thread so basically you don't need to use AsyncTask anymore. Of course you will have to take care to cancel the running requests on rotation or when user exits your activity.

这篇关于如何使用Volley库Android执行简单的异步任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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