san*_*h01 3 android android-syncadapter robospice android-volley
我的应用程序需要定期向服务器请求新数据.我已经研究过这个,很多人建议使用同步适配器与服务器同步,但是我的要求发生了变化,我需要做以下过程.是否仍然建议使用同步适配器,或者我可以使用任何其他库来有效地生成以下Http请求序列.
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
ZipFile imageZipFile;
/*this is a http post request and the size the zipfile is around 1Mb*/
ZipFile resultFile=makeHttpPostRequest(String URL, String payload);
SomeObject result= processZipFile(resultZipFile);
saveData(result);
for(String url:result.getUrls()){
/* this is a HttpGet request which returns a zip file that
contains 8 images , total size of zip would be around 200kb*/
imageZipFile= makeHttpGetRequest(url);
saveImageZipToDisk(imageZipFile)
}
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在发出Http Post请求以获取包含图像URL的一些数据,并使用这些URL来生成新的HttpGet请求.我需要POST的结果以及我的应用程序运行的图像.
这是使用同步适配器的有效方法还是这是完全不可接受的?或者我可以使用Volley/Robo spice将图像请求生成到多个线程吗?对不起,我是新手,但这是我一直在努力解决的问题.
更新:
因此,在回顾了Volley和Robospice的优点和缺点之后,我正在使用凌空,因为我可以自定义代码并对缓存机制有更多的控制权.
所有替代方案都应该有效.
使用异步适配器,您将获得:
使用Volley,您将获得:
使用RoboSpice,您将获得:
| 归档时间: |
|
| 查看次数: |
1713 次 |
| 最近记录: |