Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Trying to download page source in android but code requires a minimum of version 3 SDK but rest requires minimum 11

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Trying to download page source in android but code requires a minimum of version 3 SDK but rest requires minimum 11

    I'm trying to download a web page source within android using Java, but else where 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 minimum SDK version is set to 3.

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

      public void getHtml() throws ClientProtocolException, IOException
        {
            HttpClient httpClient = new DefaultHttpClient();
            HttpContext localContext = new BasicHttpContext();
            HttpGet httpGet = new HttpGet("WebSiteAddress");
            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 11


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


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Trying to download page source in android but code requires a minimum of version 3 SDK but rest requires minimum 11

    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Trying to download page source in android but code requires a minimum of version 3 SDK but rest requires minimum 11

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/85476-trying-download-webpage-source-but-code-requires-minimal-sdk-version-3-whereas.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


Similar Threads

  1. Double Negative VFX, London (UK) requires a Java Programmer ASAP!
    By natalie_dneg in forum Paid Java Projects
    Replies: 1
    Last Post: September 11th, 2012, 09:39 AM
  2. Minimum Spanning Tree
    By Undertaker in forum Algorithms & Recursion
    Replies: 1
    Last Post: March 17th, 2012, 09:47 AM
  3. [SOLVED] Found String Requires Double Problem.
    By NPotter86 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 17th, 2011, 01:24 PM
  4. Minimum value of objects in ArrayList
    By Sputnik in forum Loops & Control Statements
    Replies: 2
    Last Post: October 23rd, 2010, 01:20 PM