开发者

how to process http response and print the string on android screen

开发者 https://www.devze.com 2023-03-07 17:20 出处:网络
I\'ve made a made a application which is deployed on the Google app engine. I\'ve connected it with my android apk using http request and response .

I've made a made a application which is deployed on the Google app engine. I've connected it with my android apk using http request and response . Now my response is coming in the form of a string which contain data in form of html Now I want that only the开发者_如何学运维 message from my string should be printed and not the html tags and that to be On the android screen.

What should I do to achieve it??


//the function will return a response String;

private String doHTTPRequest(String url){

    String results = "ERROR";
    try
    {
        HttpClient hc = new DefaultHttpClient();
        HttpPost post = new HttpPost(url);

        HttpResponse rp = hc.execute(post);

        if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
        {
            results = EntityUtils.toString(rp.getEntity());
        }
    }catch(IOException e){
        e.printStackTrace();
    }
    return results;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消