• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Andrew Tyrer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 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)
 
Ron McLeod
Bartender
Pie
Posts: 1032
65
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did it die with a NetworkOnMainThreadException exception? This was introduced in API 11.
 
Andrew Tyrer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More than likely. When I use it with a minimum SDK set to 11, the described error occurs



What is the fix for this? Is there another method which actually works?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The fix is not to do network I/O on the UI thread. I generally use an AsyncTask for network activity.

Should the issue mentioned by Ron turn out to be the culprit, you may want to enter StrictMode in all your Android apps to warn you in case the app does something it should not.

Also note that while generally Android is backwards compatible, sometimes new versions show different behavior. See http://developer.android.com/about/versions/android-4.4.html#Behaviors, http://developer.android.com/about/versions/android-4.3.html#Behaviors and http://developer.android.com/about/versions/android-4.2.html#Behaviors for recent examples.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic