2015-11-05 123 views
-2

我是Android開發新手,現在我正在開發谷歌地圖的小應用程序。我已經集成谷歌地圖,但現在我想在地圖上顯示谷歌地方,因此我想調用谷歌API的Web服務來獲取位置,但我不知道如何在這裏調用android.enter代碼中的web服務如何在android中調用web服務

enter code here 

公共無效的getLocation()

{ 
    HttpClient httpClient = new HttpClient() 
    AsyncHttpClient client =new AsyncHttpClient(); 
} 

回答

0

你可以調用地址與HttpConnection

例如:

public String getValuefromUrl(String url) 
{ 
    try 
    { 
     DefaultHttpClient httpClient = new DefaultHttpClient(); 
     HttpGet httpGet = new HttpGet(url); 
     ResponseHandler<String> resHandler = new BasicResponseHandler(); 
     String page = httpClient.execute(httpGet, resHandler); 
     Log.v("PAGE",page); 
     return page; 
    } 
    catch(Exception ex) 
    { 
     ex.printStackTrace(); 
     return "zero"; 

    } 
}