Skip to content

Commit

Permalink
Volley sınıfı kullanımı
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Karakoç committed Jan 4, 2016
0 parents commit be469c4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Volley/volleyGetOrnek.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest strRequest = new StringRequest(Request.Method.GET, "apiURL",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject o = new JSONObject(response);
JSONArray values = o.getJSONArray("sonuc");
for (int i = 0; i < values.length(); i++) {
JSONObject sonuc = values.getJSONObject(i);
}
} catch (JSONException ex) {
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(volleyRequest.this, error.toString(), Toast.LENGTH_SHORT).show();
}
});
strRequest.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 1, 1.0f));
queue.add(strRequest);
9 changes: 9 additions & 0 deletions Volley/volleyHakkinda.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Volley s�n�f�n� kullanmam�z i�in bilmemiz gereken baz� bilgiler;

1. build.gradle dosyas�m�z�n dep'i i�ine eklememiz gereken gradle;
�rn; 'com.mcxiaoke.volley:library:1.0.19' �eklindedir. Siz a�a��dan en son s�r�m�n� al�p projenize ekleyebilirsiniz.
http://mvnrepository.com/artifact/com.mcxiaoke.volley/library

��e yarayacak linkler;
1- https://github.com/mcxiaoke/android-volley
2- http://developer.android.com/training/volley/index.html
31 changes: 31 additions & 0 deletions Volley/volleyPostOrnek.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest strRequest = new StringRequest(Request.Method.POST, "apiURL",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject o = new JSONObject(response);
JSONArray values = o.getJSONArray("sonuc");
for (int i = 0; i < values.length(); i++) {
JSONObject sonuc = values.getJSONObject(i);
}
} catch (JSONException ex) {
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(volleyRequest.this, error.toString(), Toast.LENGTH_SHORT).show();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("put1", "value1");
params.put("put2", "value3");
return params;
}
};
strRequest.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 1, 1.0f));
queue.add(strRequest);

0 comments on commit be469c4

Please sign in to comment.