I'm having trouble reading text from a file in the Android workspace using the URL class. I get a NetworkOnMainThreadException. The same exact code works outside of the Android workspace, so it must be a network or permissions issue. I've generated a basic text file from the link specified.
It appears that it is failing on url.openStream.
Below is my code, followed by my manifest file (where I've added the uses-permissions line already.)
static public String[] barList()
{
ArrayList bars = new ArrayList();
try{
URL url = new URL("****");
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
String line = br.readLine();
while(line != null)
{
bars.add(line);
line = br.readLine();
}
br.close();
}
catch (IOException e) {
e.printStackTrace();
}
return (String[])bars.toArray();
}
Here is the manifest file.
package="aexp.explist">