Skip to content

Instantly share code, notes, and snippets.

@mortenjust
Last active July 27, 2019 17:25
Show Gist options
  • Save mortenjust/e4549bc0ab2c0473a385 to your computer and use it in GitHub Desktop.
Save mortenjust/e4549bc0ab2c0473a385 to your computer and use it in GitHub Desktop.
Adding Volley to Android Studio #android
// from https://developer.android.com/training/volley/simple.html
// 1. Create a request queue
RequestQueue queue = Volley.newRequestQueue(this);
// 2. Create the request with the callback
String url ="http://www.mortenjust.com";
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("mj.volleytesting", response.substring(0, 500));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("mj.volleytesting", "that didn't work");
}
});
// 3. add the request to the request queue. Profit.
queue.add(stringRequest);
<uses-permission android:name="android.permission.INTERNET"/>
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-support-v4.jar')
compile project(':volley') // this
}
# full desscription http://www.technoburgh.com/android/android-studio-volley/
# get this outside of the project
# then in Studio, File > Import project > Pick Volley
git clone https://android.googlesource.com/platform/frameworks/volley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment