Skip to content

Instantly share code, notes, and snippets.

@pteacher
Created April 26, 2017 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pteacher/48cd566367484acb248acaf2ecd3473e to your computer and use it in GitHub Desktop.
Save pteacher/48cd566367484acb248acaf2ecd3473e to your computer and use it in GitHub Desktop.
Метод отправки данных через GET запрос (Volley)
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