enoua

Lurker
Jan 26, 2016
2
0
5
Hi everyone,

I am new here. I came to here for searching an answer. My problem is getting html content from a website. I need to get code as a string. I tried many codes for this. My latest code is below.
Code:
try
{
 
    URL url = new URL(myURL);
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    String str;
    String cumle = "";
    while ((str = in.readLine()) != null){
           cumle += str;
    }
    twicerik.setText(cumle);
    in.close();
}
catch (Exception ex)
{
    twicerik.setText(ex.getMessage());
}
Also i added to internet permission to manifest file
Code:
<uses-permission android:name="android.permission.INTERNET" />
twicerik is a textview.

When I tried to run this application it writes nothing on twicerik. Also cannot catch any error on twicerik. Can anybody help me ?
 
Last edited:
Pro tip for the forum, put your code inside code tags to make it easier for the folks that can help to read.:thumbsupdroid:

[code]
code goes here
and more code
[/code]


Code:
code goes here
and more code
 
Couple of suggestions:-

1. Try accessing myURL from a web browser. What happens?
2. Run up your app in debug mode, set a breakpoint just before the while loop and step through the code. What happens?
 
  • Like
Reactions: Unforgiven
Couple of suggestions:-

1. Try accessing myURL from a web browser. What happens?
2. Run up your app in debug mode, set a breakpoint just before the while loop and step through the code. What happens?
I solved this proble with using URLConnection and Inputstream in AsyncTask. Thanks for your answer. :thumbsupdroid: