I'm trying to display simple text I retrieve from a URL. This code works fine if I run it using System.out.println() to the java console, but when I change to Android, no text is displayed. Since I can get text to display if I hard code a string in setText, I assume my problem is in ArrayList. Thank you in advance for your help.
onCreate
try {
ArrayList<String> myData = new ArrayList<String>();
LinearLayout lView = new LinearLayout(this);
TextView myText = new TextView(this);
BufferedReader br = null;
URL url;
url = new URL("URL to plain text");
br = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
while ((inputLine = br.readLine()) != null) {
myData.add(inputLine);
}
br.close();
myText.setText(myData.get(1));
lView.addView(myText);
setContentView(lView);
} catch (IOException e) {
e.printStackTrace();
}
myText.setText(myData.get(1));can't do that on a background thread.myData.get(1)contains something because you logged it?