CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2014
    Posts
    2

    Question To make downloaded webpage source to work, requires a minimal SDK version 3 but other

    I'm trying to download a web page source within android using Java, but elsewhere in my program the minimum requirement for SDK within the Android manifest needs to be set at 11 but the below code (to download source) will only work when the minimum SDK version is set to 3.

    Is there any changes you would suggest I make to the below code


    Code:
     public void getHtml() throws ClientProtocolException, IOException  
    {  
        HttpClient httpClient = new DefaultHttpClient();  
        HttpContext localContext = new BasicHttpContext();  
        HttpGet httpGet = new HttpGet("http://www.google.com");  
        HttpResponse response = httpClient.execute(httpGet, localContext);  
        String result = "";  
      
        BufferedReader reader = new BufferedReader(  
            new InputStreamReader(  
              response.getEntity().getContent()  
            )  
          );  
      
        String line = null;  
        while ((line = reader.readLine()) != null){  
          result += line + "\n";  
          Toast.makeText(activity.this, line.toString(), Toast.LENGTH_LONG).show();  
      
        }  
      
    }

    Code above requires minimum SDK version 3

    Rest of code requires minimum SDK version 1


    When I change the minimum SDK in android manifest to 11 above code won't work


    (By won't work, I mean I get the error "Unfortunately Test has stopped" and then the app closes)

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: To make downloaded webpage source to work, requires a minimal SDK version 3 but o

    Norm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured