1. Http 用Post传参数问题:
新版本的android sdk 禁止在主线程内做post操作,需要另起一个线程进行。
public class HttpPostTask extends AsyncTask<HttpPost, Void, String>{
@Override
protected String doInBackground(HttpPost... arg0) {
// TODO Auto-generated method stub
HttpPost postRequest = arg0[0];
HttpResponse response = null;
String result = null;
try {
response = new DefaultHttpClient().execute(postRequest);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
}