我在我的gradle包装器中使用Android studio 0.50发行版和gradle 1.11-all.我有3个模块,以下是build.gradle文件.
第1单元
apply plugin: 'android'
apply plugin: 'android-test'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
androidTest.setRoot('src/test')
}
}
Run Code Online (Sandbox Code Playgroud)
第2单元
apply plugin: 'android-library'
apply plugin: 'android-test'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
release {
runProguard …Run Code Online (Sandbox Code Playgroud) 我的应用程序需要定期向服务器请求新数据.我已经研究过这个,很多人建议使用同步适配器与服务器同步,但是我的要求发生了变化,我需要做以下过程.是否仍然建议使用同步适配器,或者我可以使用任何其他库来有效地生成以下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的优点和缺点之后,我正在使用凌空,因为我可以自定义代码并对缓存机制有更多的控制权.