如何從android調用webservice?我是新來的android,任何人都可以發送一些鏈接,如何做或任何教程如何從頭開始。如何使用android adt eclipse從Android中調用Rest webService?
我想使用restwebservice進行android adt eclipse,並告訴我如何使用現有網站?
點擊按鈕後,它表明網站,如何使用http那一個?但在HTTP其只顯示字符串
如何從android調用webservice?我是新來的android,任何人都可以發送一些鏈接,如何做或任何教程如何從頭開始。如何使用android adt eclipse從Android中調用Rest webService?
我想使用restwebservice進行android adt eclipse,並告訴我如何使用現有網站?
點擊按鈕後,它表明網站,如何使用http那一個?但在HTTP其只顯示字符串
首先添加以下到您的清單。這是要求獲得訪問互聯網的權限。
<uses-permission android:name="android.permission.INTERNET" />
然後打一個web服務的最簡單方法是使用HttpClient與Android捆綁:
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(new HttpGet(URL));
StatusLine statusLine = response.getStatusLine();
if(statusLine.getStatusCode() == HttpStatus.SC_OK){
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
out.close();
String responseString = out.toString();
//Whatever you wanna do with the response
} else{
//Close the connection.
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
我們想要給我們的網址,我們想把這個代碼放在哪裏,你能告訴我一些詳細的細節,我是android新手,你能告訴我怎麼做 – Maruthi042 2013-02-22 04:58:41
在第二行中有一種叫做「URL」的東西。你在那裏給你的'URL',這是整個代碼打到一個** webservice **。你需要把它放在任何你想叫它的地方。 – SudoRahul 2013-02-22 05:00:58
你能告訴一件事,是任何lib功能是必要的。如果在那個url地方,我想把http:\\ www.ibettertechnologies.com,是否有可能,還有一件事,如果我點擊一個按鈕,它必須打開該公司地址,如何做 – Maruthi042 2013-02-22 05:30:33
這是一個偉大的鏈接「http://androidexample.com/Restful_Webservice_Call_And_Get_And_Parse_JSON_Data-_Android_Example/index.php ?view = article_discription&aid = 101&aaid = 123「 – astuter 2013-12-16 05:32:21