Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8636081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:08:14+00:00 2026-06-12T10:08:14+00:00

I’ve created an app where the user enters a name and when the button

  • 0

I’ve created an app where the user enters a name and when the button send is pressed the form from a remote server will be filled from the user input. but somehow its not working, its not filling the input box, I’m not getting any error so I’m not sure whats wrong.

here’s my code for the mainactivity.java

public class MainActivity extends Activity {
    Button send;
    EditText name;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        name = (EditText) findViewById(R.id.etFName);
        send = (Button) findViewById(R.id.bSend);

        final String sname = name.getText().toString();

        send.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                new Thread(new Runnable()
                {
                    public void run()
                    {
                        // TODO Auto-generated method stub
                        HttpClient postClient = new DefaultHttpClient();
                        String postReq = "http://10.0.2.2/formcode.php";
                        HttpPost request = new HttpPost(postReq);
                        List<NameValuePair> postParams = new ArrayList<NameValuePair>();
                        postParams.add(new BasicNameValuePair("element_8_1", sname));
                        UrlEncodedFormEntity postEntity = null;
                        try {
                            postEntity = new UrlEncodedFormEntity(postParams);
                        } catch (UnsupportedEncodingException e) {
                            e.printStackTrace();
                        }

                        request.setEntity(postEntity);

                        HttpResponse response = null;
                        try {
                            response = postClient.execute(request);
                        } catch (ClientProtocolException e) {
                            e.printStackTrace();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }).start();

                String url = "http://10.0.2.2/formcode.php";
                Intent intent = new Intent(android.content.Intent.ACTION_VIEW,  Uri.parse(url));
                startActivity(intent);
            }
        });
    }
}

thanks in advance.

EDITED

here is the site code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>App Test Form</title>
<link rel="stylesheet" type="text/css" href="./data/form_6/css/view.css" media="all" />
<script type="text/javascript" src="js/view.js"></script>
<script type="text/javascript" src="js/calendar.js"></script>
</head>
<body id="main_body" >

    <img id="top" src="images/top.png" alt="" />
    <div id="form_container">

        <h1><a>App Test Form</a></h1>
        <form id="form_6" class="digitalfuture"  method="post" action="#main_body">
                    <div class="form_description">
            <h2>App Test Form</h2>
            <p></p>
        </div>                      
            <ul >

                    <li id="li_8" >
        <label class="description">Name <span id="required_8" class="required">*</span></label>
        <span>
            <input id="element_8_1" name= "element_8_1" class="element text" maxlength="255" size="8" value="" />
            <label>First</label>
        </span>
        <span>
            <input id="element_8_2" name= "element_8_2" class="element text" maxlength="255" size="14" value="" />
            <label>Last</label>
        </span><p class="guidelines" id="guide_8"><small>Please tell us your name</small></p> 
        </li>       <li id="li_9" >
        <label class="description">Phone Number <span id="required_9" class="required">*</span></label>
        <span>
            <input id="element_9_1" name="element_9_1" class="element text" size="3" maxlength="3" value="" type="text" /> -
            <label for="element_9_1">(###)</label>
        </span>
        <span>
            <input id="element_9_2" name="element_9_2" class="element text" size="3" maxlength="3" value="" type="text" /> -
            <label for="element_9_2">###</label>
        </span>
        <span>
            <input id="element_9_3" name="element_9_3" class="element text" size="4" maxlength="4" value="" type="text" />
            <label for="element_9_3">####</label>
        </span>
        <p class="guidelines" id="guide_9"><small>Please tell us your phone number</small></p> 
        </li>       <li id="li_10" >
        <label class="description">Alternate Phone Number </label>
        <span>
            <input id="element_10_1" name="element_10_1" class="element text" size="3" maxlength="3" value="" type="text" /> -
            <label for="element_10_1">(###)</label>
        </span>
        <span>
            <input id="element_10_2" name="element_10_2" class="element text" size="3" maxlength="3" value="" type="text" /> -
            <label for="element_10_2">###</label>
        </span>
        <span>
            <input id="element_10_3" name="element_10_3" class="element text" size="4" maxlength="4" value="" type="text" />
            <label for="element_10_3">####</label>
        </span>
        <p class="guidelines" id="guide_10"><small>Please tell us an alternate phone number to contact you at</small></p> 
        </li>       <li id="li_11" >
        <label class="description" for="element_11">Email <span id="required_11" class="required">*</span></label>
        <div>
            <input id="element_11" name="element_11" class="element text medium" type="text" maxlength="255" value="your@email.com" /> 
        </div> 
        </li>

    </div>
    <img id="bottom" src="images/bottom.png" alt="" />
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:08:15+00:00Added an answer on June 12, 2026 at 10:08 am

    I think it may be because the value you’re sending in the parameters is blank. sname is set outside of the onClickListener so the value doesn’t update when the button is clicked. It just gets the value that’s already in the text box. I would recommend moving the code to an AsyncTask (There’s lots of good tutorials out there on this) as AnujAroshA suggested. You want to have something like this:

    private class SubmitForm extends AsyncTask<String, Void, Void>{
        @Override
        protected Void doInBackground(String... params) {
                    String sName = params[0];
    
                    // Rest of the code you had here
                }
    }
    

    What this will do is create a task that runs in the background and not on the UI thread. Then to run it, just modify the onClickListener to say

    public void onClick(View v) {
        new SubmitForm().execute(name.getText().toString());
    }
    

    So then this will actually start the riequest. It’s similar to the way you had it with Threads but a bit more android offical.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.