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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:03:34+00:00 2026-06-13T14:03:34+00:00

try { url= new URL(ConstantsClass.VENDOR_FOLLOW + ?UID= +android_id+&URL=’+resultfinal+’&device=android); connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestMethod(POST);

  • 0
         try 
         {

            url= new URL(ConstantsClass.VENDOR_FOLLOW + "?UID=" +android_id+"&URL='"+resultfinal+"'&device=android");


                connection = (HttpURLConnection) url.openConnection();
                connection.setDoOutput(true);
                connection.setRequestMethod("POST");

                request = new OutputStreamWriter(connection.getOutputStream());
                request.flush();
                request.close();
                request.write("Hello!!!");

                String line = "";
                InputStreamReader isr = new InputStreamReader(connection.getInputStream());
                BufferedReader reader = new BufferedReader(isr);

                StringBuffer sb = new StringBuffer();

                while((line=reader.readLine())!=null) {
                    sb.append(line + "&");
                }

                response = sb.toString();
                //response.getEntity().getContent();

                Log.i("Test", "updated response: " + response);



            }
         catch (IOException e) {
              e.printStackTrace();
          }

            Log.i("Test", "**************url list********************" + url);
         tag_text.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    Intent in=new Intent(context,LinkWebView.class);
                    in.putExtra("vendorUrl", resultfinal);
                    context.startActivity(in);      
                    //postData();
                }
            });
             }

    tag_text.setTextSize(16);
    return view;

}   

Hi i am new to android and I am trying to pass values from the url to the server but i am getting null values passed on the server side. Update response is giving null. My server side values dont give any values to me. I need to pass the url, android_id and device from the url that is given above. I tried the httpclient also but it gives me null values in that as well.

  • 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-13T14:03:36+00:00Added an answer on June 13, 2026 at 2:03 pm

    you should try below code its running very well for me.

       // ADD YOUR REQUEST DATA HERE  (you can pass number of variable).
        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("Your_var_1", value));
        nameValuePairs.add(new BasicNameValuePair("Your_var_2", value));
    

    Now establish your web connection like

    (1) Sending simple string to server

        try
        {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("your url only ex:www.google.com/abc");
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpParams httpParameters = new BasicHttpParams();
            DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
        } catch (Exception e) 
        {   
            Log.e("Loading Runnable Error in http connection  :", e.toString());
        }
    

    (2) Send JSON Encode string to server

    HttpClient client = new DefaultHttpClient();
    HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); //Timeout Limit
    HttpResponse response;
    JSONObject json = new JSONObject();
    
    try {
    HttpPost post = new HttpPost(URL);
    json.put("user_name", "chintan");
    json.put("password", "khetiya");
    StringEntity se = new StringEntity( json.toString());  
    se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
    post.setEntity(se);
    response = client.execute(post);
    
     /*Checking response */
    if(response!=null){
    is = response.getEntity().getContent(); //Get the data in the entity
     }
    
    } catch(Exception e) {
    e.printStackTrace();
    createDialog("Error", "Cannot Estabilish Connection");
    }
    

    Response will same in both case

    try 
        {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) 
            {
                sb.append(line + "\n");
            }
            is.close();
            result = sb.toString();
        }
        catch (Exception e) 
        {   
            Log.e("Loading Runnable Error converting result :", e.toString());
        }
    

    Now at the end result contain whole output string now its depend on you how you will read your data. using json or else. i am doing using json so put example code of it may be helpful to you.

    JSONObject json_data = new JSONObject(result);// its a string var which contain output. 
            my_output_one = json_data.getString("var_1"); // its your response var form web.
            my_output_two = json_data.getString("var_2");
    

    Now its over you have two variable which having any kind of value and use any were.

    Now this will helpful to you. if you have any query let me know.

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

Sidebar

Related Questions

I am using simple urlconnection like this: url = URL+getClient&uid=+cl_id; URL url = new
I try to get string from this url: http://autoc.finance.yahoo.com/autoc?query=google&callback=YAHOO.Finance.SymbolSuggest.ssCallback When I look at this
If I try to encode the url http://herthabsc.de/index.php?id=3631&tx_ttnews[tt_news]=13144&cHash=9ef2e9ee006fb16188ebf764232a0ba9 with urlencode() or http_build_query() it gives
I'm using Android's httpclient to connect to a domain as follows: try { URL
I made the following code: try { URL url = new URL(http://bbc.com); is =
I'm new to Java and Android development and try to create a simple app
I have simple code : URL url; BufferedReader in = null; HttpURLConnection connection; InputStream
i want to add ?orderBy=countryasc to my current url. I try with Request.Url but
I try to get this following url using the downloadURL function as follows: http://www.ncbi.nlm.nih.gov/nuccore/27884304
I try to start action with service (or activity) from an url. (with params)

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.