The problem is when I enter a string or a name in the edittext, it cannot be appeared in the textview after i press the button "Send request". I don't know how to fix it.
Please help me!

package com.androidexample.httpgetexample;


import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class HttpGetAndroidExample extends Activity {

    TextView content;
    EditText userID;

    protected void onCreate(Bundle savedInstanceState) {

        content = (TextView) findViewById(;
        userID = (EditText) findViewById(;
        Button saveme = (Button) findViewById(;

        saveme.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                // ALERT MESSAGE

                        "Please wait, connecting to server.", Toast.LENGTH_LONG)
                try {

                    String userIDValue = URLEncoder.encode(userID.getText().toString(), "UTF-8");
                    // HttpClient Client = new DefaultHttpClient();
                    String URL = ""
                            + userIDValue;

                    new HttpAsyncTask().execute(URL);

                } catch (UnsupportedEncodingException ex) {

    public static String GET(String url) {
        InputStream inputStream = null;
        String response = new String(); 
        // result="";
        try {

            if (inputStream != null)
                response = convertInputStreamToString(inputStream);

                response = "Did not work!";

        } catch (Exception e) {
            Log.d("InputStream", e.getLocalizedMessage());

        return response;

    private static String convertInputStreamToString(InputStream inputStream)
            throws IOException {
        BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(inputStream));
        String line = "";
        // String result = "";
        StringBuilder result = new StringBuilder();
        while ((line = bufferedReader.readLine()) != null)
             result.append(line + "\n");

        return result.toString();


    private class HttpAsyncTask extends AsyncTask<String, Void, String> {
        protected String doInBackground(String... urls) {

            return GET(urls[0]);

        // onPostExecute displays the results of the AsyncTask.
        protected void onPostExecute(String result) {
            Toast.makeText(getBaseContext(), "Received!", Toast.LENGTH_LONG)

            // String type = mainObject.getString("capsuleType");

Well either you posted wrong code piece or you did not implemented this yet and trying to trick us in doing your work.

Either way there is no send button and no action associated with it to do what you ask to do

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.