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;
}
嗨,我是新來的android和我試圖從URL傳遞值到服務器,但我得到空值傳遞到服務器端。更新響應爲空。我的服務器端值不給我任何價值。我需要從上面給出的url傳遞url,android_id和device。我也嘗試了httpclient,但它也給了我null值。http post方法將空值傳遞給服務器
檢查您是否在傳遞到URL之前正確地獲得了所有值.BTW「resultfinal」包含哪些內容? – AndroidLearner
resultfinal有一個我正在傳遞的網址。而且我已經在烤麪包上打印了這個url值,它正確地給出了所有的值 –
android_id是一個數字還是一個字符串? – Bhavin