Is there a way to extract the text from a website (That only has text and can be updated by the webserver) and put it in a text view or string variable so that it will show the text in my android app.
Also, there are different languages based on what region 开发者_运维问答your phone is in (English being the default).
This is what I've been using so far
    public String getText(String uri) {
    HttpClient client1 = new DefaultHttpClient();
    HttpGet request = new HttpGet(uri);
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    try {
        String response_str = client1.execute(request, responseHandler);
        return response_str;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return "";
    }
Unfortunately I haven't figured out a way to get rid of the html code or how to change the website being passed in depending on the region. Thanks
If the html header, body color, etc keeps a static format (such as always ending in <br>), you can use the split(...) method in the String class.
this is a very simple function that I use to make my code look cleaner.
    public String getText(String uri) {
    HttpClient client1 = new DefaultHttpClient();
    HttpGet request = new HttpGet(uri);
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    try {
        String response_str = client1.execute(request, responseHandler);
        return response_str;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return "";
    }
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论