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 6790857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:46:34+00:00 2026-05-26T17:46:34+00:00

I have a submit button created in which I am calling a method call2

  • 0

I have a submit button created in which I am calling a method “call2” that contains the code
to do an HttpPost using JSON

      final Button submit = (Button) findViewById(R.id.Button03);
      submit.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v)
          {

            // Perform action on click
             Toast.makeText(display.this,"You have selected to submit data of students",Toast.LENGTH_SHORT).show();
             call2();           
          }

      });      

   } //OnCreate method ends

  After that I have my call2 method as follows:

       public String call2()
        {
      String result="";
      HttpParams httpParams = new BasicHttpParams();
      HttpPost httppost = new HttpPost("http://10.0.2.2/enterdata/Service1.asmx");
          HttpClient client = new DefaultHttpClient(httpParams);

       try
     {


     JSONArray jsArray = new JSONArray(items2);
     jsArray.put(items2);   

     int TIMEOUT_MILLISEC = 10000;  // = 10 seconds

     HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
     HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);


     httppost.setEntity(new ByteArrayEntity(
     result.toString().getBytes("UTF8")));
     HttpResponse response = client.execute(httppost);

     if(response.toString()=="success")
     {
     System.out.println(response);

     }


    }

     catch(Exception e)
        {
          e.printStackTrace();

        } 
     return result;

 }

my web service code that returns “success” after inserting the records

     public class Service1 : System.Web.Services.WebService
     {

    [WebMethod]
    public String put(String value)
    {
        int count=1;
        int rows;

        SqlConnection myConnection = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=student;User ID=sa;Password=123");
        try
        {
            myConnection.Open();
            count++;
            SqlCommand myCommand = new SqlCommand();
            myCommand.Connection = myConnection;
            myCommand.CommandText = "insert into record values('"+ count +"','" + value + "')";
            myCommand.Parameters.Add("@value", SqlDbType.VarChar).Value = value;
            rows = myCommand.ExecuteNonQuery();
            SqlDataReader myReader = myCommand.ExecuteReader();

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        finally
        {
            myConnection.Close();
        }

        return "success";
    }

this is log cat after I remove the If statement of my Android code in method call2

   11-10 09:19:28.447: INFO/System.out(412):   org.apache.http.message.BasicHttpResponse@44f5d6b8
   11-10 09:22:39.957: WARN/KeyCharacterMap(440): No keyboard for id 0
   11-10 09:22:39.957: WARN/KeyCharacterMap(440): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
   11-10 09:22:40.447: DEBUG/dalvikvm(124): GC_EXPLICIT freed 1224 objects / 67584 bytes in 363ms
   11-10 09:22:42.498: DEBUG/dalvikvm(440): GC_FOR_MALLOC freed 2924 objects / 197768 bytes in 80ms
   11-10 09:22:42.587: INFO/System.out(440): org.apache.http.message.BasicHttpResponse@44f357a0

Now when I run my code, I am unable to see any response in the logcat. My println statement is not getting executed and I don’t know why

Can someone help me?

  • 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-05-26T17:46:34+00:00Added an answer on May 26, 2026 at 5:46 pm

    As yorkw said, I doubt response.toString() gives you the response text. This is how I usually check my responses:

    if (response.getStatusLine().getStatusCode() == 200)
    {
        HttpEntity entity = response.getEntity();
        json = EntityUtils.toString(entity);
    }
    

    Obviously if the response code was not 200 there would be some sort of error handling

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

Sidebar

Related Questions

I have a button element that I've created like so: $submit = new Zend_Form_Element_Button('submit');
I have a submit button that is a block of HTML code because of
I have a form (AddNewCamper), which contains a textbox and a submit button. In
I am using ColorBox inline functionality and I have created a button which I've
I have a submit button that changes when the user hovers his mouse over
I have a search box that doesn't have a submit button, I need to
Using the AngularJS framework, how do I have the Submit button both update the
I have a HTML table inside which I have a submit button. Now, I
I have the following code that works fine on my localhost using IIS7 but
I'm using primefaces' accordion panel. Inside the tabs i have forms which are created

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.