Created
April 26, 2017 13:55
-
-
Save pteacher/48cd566367484acb248acaf2ecd3473e to your computer and use it in GitHub Desktop.
Метод отправки данных через GET запрос (Volley)
This file contains 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
public void sendRequest(View view) { | |
RequestQueue queue = Volley.newRequestQueue(getApplicationContext()); | |
String a = aValue.getText().toString(); | |
String b = bValue.getText().toString(); | |
String url = "https://pteachertest.herokuapp.com/calc/?a="+a+"&b="+b; | |
StringRequest request = new StringRequest(Request.Method.GET, url, | |
new Response.Listener<String>() { | |
@Override | |
public void onResponse(String s) { | |
textView.setText(s); | |
} | |
}, new Response.ErrorListener() { | |
@Override | |
public void onErrorResponse(VolleyError volleyError) { | |
textView.setText("Ошибка запроса: " + volleyError.getMessage()); | |
} | |
}); | |
queue.add(request); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment