[android-developers] Re: fiel download, java.net.URL, streams
Did you allow INTERNET permission?
I don't know why do you did this: http.connect(); if you already
connected: url.openConnection();
Please, test your connection for available bytes, maybe your stream is
empty, if looking on that: URL url = new URL("http://
www.google.at/");
On 14 Жов, 15:09, raa <raa....@gmx.at> wrote:
> Hey Guys,
> i am from austria
>
> i am developing android a few days now and startet to write an
> application that gets a file from a server to display the content.
>
> I have this code here
>
> try {
> super.onCreate(icicle);
> setContentView(R.layout.main);
> EditText myEditText =
> (EditText)findViewById(R.id.myEditText);
>
> URL url = new URL("http://www.google.at/");
> HttpURLConnection http = (HttpURLConnection)
> url.openConnection();
> http.connect();
> BufferedReader rd = new BufferedReader(new
> InputStreamReader(http.getInputStream()));
> StringBuilder sb = new StringBuilder();
> String line = "";
> while ((line = rd.readLine()) != null) {
> sb.append(line + '\n');
> }
> String text = sb.toString();
> text = text.substring(1, 5);
> myEditText.setText(text);
>
> } catch (IOException ex) {
>
> Logger.getLogger(MainActivity.class.getName()).log(Level.SEVERE, null,
> ex);
> ..........
>
> The strange thing is that nothing is shown in the TextField. If I test
> the code in a standard java project the printing of the data (with
> println) works correctly in the console. But when i run it on the
> android vmachine nothing is shown. I got no more ideas left to proof
> the code. Anyone has some advices for a newcomer?
>
> Kindly Regards from austria ;) and happy developing
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home