2) I see multiple branches here and no documentation on which branch is to start with. Which branch should I use to start with?
Google I | O 演示文稿中的指令只是克隆 git repo,默认情况下它将从 master分支中提取。
3) How to integrate this library in your own project? What approach is better: Make Volley as a standalone library project and spin a jar and put it in your project or Copy the all source code inside your project?
The instructions from the Google I|O presentation were to add the source code to your project. Personally, I find this to be a bizarre approach.
将项目导入 Android Studio (在导入 Android Studio 时,我通常选择项目的 gradle 文件)
建立项目。(我不得不改变分级构建设置,以反映最新的构建工具和分级版本,但它通常是最新的)。
在文件资源管理器中,导航到 [your local path to volley]/build/intermediate/bundles/
在 debug和 release文件夹中都可以找到一个名为 classes.jar的 JAR 文件。
将任一 JAR 文件复制到 libs/文件夹中。
同步,然后你就完成了。
日食:
通过 Git 克隆 Volley 存储库。
将项目导入 Eclipse。
右键单击项目并选择 出口..。
选择 Java/JAR 文件。
We're only interested in the src folder and nothing else. The easiest way to make sure only it is selected is to deselect the project and then select the src folder inside.
JsonArrayRequest mJsonRequest = new JsonArrayRequest(url,
new Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
// here you can parse response and use accordingly
}
}, new ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// here you will receive errors and show proper message according to error type
}
});
Please bear in mind that there are 有各种各样的克隆人,他们对图书馆进行了改进. It might be necessary to integrate them and compile your private enhanced version of the library.
repositories {
maven {
url 'https://github.com/Goddchen/mvn-repo/raw/master/'
}
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v4:20.+'
compile 'com.android:volley:1.+'
}
Click on Try Again which should right away appear on the top of the file, or just Build it if not
The main "advantage" here is, that this will keep the version up to date for you, whereas in the other two cases you would have to manually update volley.
On the "downside" it is not officially from google, but a third party weekly mirror.
But both of these points, are really relative to what you would need/want.
Also if you don't want updates, just put the desired version there instead e.g. compile 'com.mcxiaoke.volley:library:1.0.7'.
I love to work with 齐射. To save development time i tried to write small handy library Gloxey 网络管理器 to setup Volley with my project. It includes JSON 解析器 and different other methods that helps to check network availability.
库提供了 ConnectionManager.class,其中提供了用于 排球线和 截击 JSON请求的不同方法。可以使用或不使用标头来发出 获取,放入,发布,删除请求。
You can read full documentation here.