2012-05-16 38 views
1

我需要從我的android手機上訪問網站,本網站接受一些POST值。從我的Android應用程序打開網頁,發佈值

當我從我的電腦一樣,是用PHP形式:

<form name="form1" method="post" action="scripts/pago.php"> 

我可以打開一個網站,這個代碼:

 Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com")); 
     startActivity(browserIntent); 

它打開沒有問題的瀏覽器,但,我如何添加帖子值?

預先感謝您。

回答

1

嘗試了這一點:

public void postData() throws Exception { 


HttpClient client = new DefaultHttpClient(); 
HttpPost httppost = new HttpPost("http://www.xyz.com"); 

List<NameValuePair> list = new ArrayList<NameValuePair>(1); 

list.add(new BasicNameValuePair("name","ABC"); 

httppost.setEntity(new UrlEncodedFormEntity(list)); 

HttpResponse r = client.execute(httppost); 

} 
相關問題