简体   繁体   中英

how to call web service in android

i am new in Android development and now i am developing small application of google map. i have integrated google map,but now i want to show google places on map therefore i want to call google api web service to get locations, but i don't know how to call web service in android.enter code here

enter code here

public void getLocation()

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

You can call Url's with HttpConnection .

For Example:

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";  

    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM