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

  • Home
  • SEARCH
  • 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 7927319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:15:02+00:00 2026-06-03T19:15:02+00:00

ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair( product_name, product_name)); nameValuePairs.add(new BasicNameValuePair(brand, brand_product)); nameValuePairs.add(new BasicNameValuePair(reference_price,

  • 0
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();


                        nameValuePairs.add(new BasicNameValuePair(
                                "product_name", product_name));
                        nameValuePairs.add(new BasicNameValuePair("brand",
                                brand_product));
                        nameValuePairs.add(new BasicNameValuePair("reference_price",
                                mrp_product));
                        nameValuePairs.add(new BasicNameValuePair("model",
                                model_product));

                        HttpPost httppost = new HttpPost(
                                "http://10.0.2.2/wic3/wic2/product/doadd");

                        httppost.setEntity(new UrlEncodedFormEntity(
                                nameValuePairs));
                        ResponseHandler<String> responseHandler = new BasicResponseHandler();
                        String response = SignUpActivity.httpclient.execute(
                                httppost, responseHandler);
                        Log.d("response", response);

                        Intent intent = new Intent(ShareProductActivity.this, ShareActivity.class);
                        startActivity(intent);

this gives me an exception:

05-07 14:56:19.105: D/exception(1137): org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused

i searched for this and everyone says change 127.0.0.1 to 10.0.2.2, but i am not using 127.0.0.1
I guess the problem is at this step:

String response = SignUpActivity.httpclient.execute(httppost, responseHandler);
  • 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-03T19:15:05+00:00Added an answer on June 3, 2026 at 7:15 pm

    Localhost by definition refers to the hosting system – the android device itself. Unless you are trying to contact a server running on the android device, it will not work for you.

    Follow the advice of those who suggested that you change the 127.0.0.1 (which is what localhost is a name for) to the forwarding alias for the machine hosting the emulator.

    Note however, that this only works with the emulator and not with real devices.

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

Sidebar

Related Questions

i write this code in main.java ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); try{ HttpClient httpclient
This is roughly the code I'm working with now: List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
I'm dealing with doubles and looking for the double equivalent of this... ArrayList<NameValuePair> nameValuePairs
public static ArrayList GetStudentAsArrayList() { ArrayList students = new ArrayList { new Student() {
I have an arraylist namelist in my model and in my view I need
My question is very similar to Java: HTTP Post to create new "Product" in
my java function private void adddataintophp(String title, String date, String time, String channel){ ArrayList<NameValuePair>
I want to make a nested nameValuePairs something like this: List nameValuePairs = new
Here is my HttpClient request: HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new
I have an arraylist that gets different type of values in it, 1st value->

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.