我有一個網址www.abc.com/check ...我在這個地址上創建了一個Web服務來接收數據。通過Android應用程序,我使用以下代碼向此地址發送一些數據:android:如何確保我使用httppost正確發佈
public class TestappActivity extends Activity {
EditText ch;
Button btn;
InputStream is;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ch=(EditText)findViewById(R.id.ch);
btn=(Button)findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
sendData();
}
});
}
private void sendData() {
Log.i(getClass().getSimpleName(), "send task - start");
HttpParams p=new BasicHttpParams();
p.setParameter("name", ch.getText());
HttpClient client = new DefaultHttpClient(p);
try {
HttpResponse response=client.execute(new HttpPost("http://www.abc.com/check"));
is=response.getEntity().getContent();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.i(getClass().getSimpleName(), "send task - end");
}
}
如何查找我的帖子是否成功?當我發佈一些東西時,我會回來什麼。 ?