Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface ResultListener {
- public void onResult(JSONObject result);
- }
- private ResultListener listener;
- public JSONObject logar(final String usuario , final String senha){
- Map<String, String> postParam= new HashMap<String, String>();
- postParam.put("username", usuario);
- postParam.put("password", senha);
- JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
- "http://192.168.0.13:8088/onblox/login", new JSONObject(postParam),
- new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject response) {
- Log.d("tag", response.toString());
- Toast.makeText(getApplicationContext(), response.toString(), Toast.LENGTH_LONG).show();
- listener.onResult(response);
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- VolleyLog.d("tag" , "Error: " + error.getMessage());
- Toast.makeText(getApplicationContext(),error.getMessage().toString(), Toast.LENGTH_LONG).show();
- }
- }) {
- };
- jsonObjReq.setTag("TAG");
- // Adding request to request queue
- rq.add(jsonObjReq);
- MainActivity objectLoader = new MainActivity();
- return (JSONObject)listener;
- }
- public void setResultListener(ResultListener listener){
- this.listener = listener;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement