Last active
July 27, 2019 17:25
-
-
Save mortenjust/e4549bc0ab2c0473a385 to your computer and use it in GitHub Desktop.
Adding Volley to Android Studio #android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-permission android:name="android.permission.INTERNET"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
compile fileTree(dir: 'libs', include: ['*.jar']) | |
compile files('libs/android-support-v4.jar') | |
compile project(':volley') // this | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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