Skip to content
This repository has been archived by the owner on Feb 26, 2018. It is now read-only.

can't send JsonObject with JsonObjectRequest #152

Open
picachugame001 opened this issue Mar 25, 2016 · 1 comment
Open

can't send JsonObject with JsonObjectRequest #152

picachugame001 opened this issue Mar 25, 2016 · 1 comment

Comments

@picachugame001
Copy link

I'm trying with code:

public class VinhNT_HTTP implements Response.Listener,Response.ErrorListener {
private VinhNT_Activity context;
private RequestQueue queue;
public VinhNT_HTTP(VinhNT_Activity nguCanh){
context = nguCanh;
// Instantiate the cache
Cache cache = new DiskBasedCache(context.getCacheDir(), 1024 * 1024); // 1MB cap
cache.clear();
//
// Set up the network to use HttpURLConnection as the HTTP client.
Network network = new BasicNetwork(new HurlStack());
//
// Instantiate the RequestQueue with the cache and network.
queue = new RequestQueue(cache,network);

    //


}
public  void sendRequest() {
    //
    queue.start();
    try{
        String url ="http://192.168.0.101/bongda";
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("user","VinhNT");
        jsonBody.put("function", "login");
        JsonObjectRequest a = new JsonObjectRequest(Request.Method.POST,url,jsonBody,this,this);
        queue.add(a);
        //queue.stop();

    }
    /*catch (JSONException  e){
        Log.d("Error","JSONException");
    }*/
    catch (Exception e){
        Log.d("Error","JSONException"+ e.getMessage());
    }

}
public void cancelAll(){
    queue.cancelAll(context.getTitle_VinhNT());
}

@Override
public void onResponse(JSONObject response) {
    Log.d("Ket noi","OK roi nhe");
}

@Override
public void onErrorResponse(VolleyError error) {
    Log.d("Ket noi","Loi roi");
}

}

That doesn't send JSONObject to PHP server:

please help me, many thank

@picachugame001
Copy link
Author

OK, I've fix it, Sory

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant