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.
Please call the flush after write and close the stream in finally block. Check out the following code:
you should try below code its running very well for me.
Now establish your web connection like
(1) Sending simple string to server
(2) Send JSON Encode string to server
Response will same in both case
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.
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.