Dominik Thalhammer
- Forum posts: 1
Feb 10, 2012, 5:35:52 PM via Website
Feb 10, 2012 5:35:52 PM via Website
Hello,
I'm new to Android and wanted to write an Application that retrives an XML file and displays it.
But the Problem is at Downloading
I've tried with this code but it does not work in Simulator.
The Code compiles fine, but if I press the Button to start, nothing happens.
EDIT:
Found the Problem, I forgot to set the permissions correctly
I'm new to Android and wanted to write an Application that retrives an XML file and displays it.
But the Problem is at Downloading
I've tried with this code but it does not work in Simulator.
1URL url = new URL("http://192.168.20.42/temp/filelist.xml");
2 urlConnection = (HttpURLConnection) url.openConnection();
3 //InputStream in = new BufferedInputStream(urlConnection.getInputStream());
4 BufferedReader r = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
5
6 StringBuilder total = new StringBuilder();
7 String line;
8 while ((line = r.readLine()) != null) {
9 total.append(line);
10 }
11 EditText text = (EditText) findViewById(R.id.editText1);
12 text.setText(total);
13 }catch(IOException e)
14 {
15
16 }
17 finally {
18 urlConnection.disconnect();
19 }
I have no Idea why. Could you tell me why ?2 urlConnection = (HttpURLConnection) url.openConnection();
3 //InputStream in = new BufferedInputStream(urlConnection.getInputStream());
4 BufferedReader r = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
5
6 StringBuilder total = new StringBuilder();
7 String line;
8 while ((line = r.readLine()) != null) {
9 total.append(line);
10 }
11 EditText text = (EditText) findViewById(R.id.editText1);
12 text.setText(total);
13 }catch(IOException e)
14 {
15
16 }
17 finally {
18 urlConnection.disconnect();
19 }
The Code compiles fine, but if I press the Button to start, nothing happens.
EDIT:
Found the Problem, I forgot to set the permissions correctly
— modified on Feb 10, 2012, 7:37:16 PM
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.