Usman Qadeer Usman Qadeer -4 years ago 49
Java Question

I want to print out the request using toast

I want to print out the request in android but when I use toast method it, cannot resolve the method.

Here is my code.

AsyncHttpClient client = new AsyncHttpClient();
client.get("http://localhost/moodle/webservice/rest/server.php?wstoken=0ac06623c66a3dd0e0e431f872a74710&wsfunction=core_user_create_users",params ,new AsyncHttpResponseHandler();

Toast.makeText(getApplicationContext(), client, Toast.LENGTH_LONG).show();

I want to print out the request.

Answer Source

You need to read documentation /implementation of AsyncHttpClient first. You won't get response like that. You need to Override onSuccess/onFailure methods for your AsyncHttpResponseHandler()

client.get("http://localhost/moodle/webservice/rest/server.php?wstoken=0ac06623c66a3dd0e0e431f872a74710&wsfunction=core_user_create_users",params ,new AsyncHttpResponseHandler(){
        public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
        Toast.makeText(getApplicationContext(),  new String(responseBody), Toast.LENGTH_LONG).show();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download