1

I use 4.4.2 Android version. I want to read a url's html code. This url has this code: echo"1";

I'm trying a lot of codes but it isn't work. Pls don't lock this topic. My error: Application stopped.

HttpClient don't work.

android: 4.4.2

program: Android Studio

My AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>

My java code:

try {
    URL u = new URL("http://www.google.com");
    BufferedReader br = null;
    br = new BufferedReader(new InputStreamReader(u.openStream()));
    br.close();
} catch (IOException e) {
    e.printStackTrace();
}
5
  • 4
    Possible duplicate of How to get HTML source code from url in android? Commented Jul 11, 2016 at 13:03
  • it isn't work. It gives error. I solved this problem one year ago but it is giving errors now. Commented Jul 11, 2016 at 13:14
  • If it gives some errors, please post the logcat of the error along with the relevant code. Commented Jul 11, 2016 at 13:16
  • 2
    try use Okhttp get method Commented Jul 11, 2016 at 13:18
  • Error:(40, 29) error: cannot find symbol class HttpClient Error:(40, 57) error: cannot find symbol class DefaultHttpClient Error:(41, 29) error: cannot find symbol class HttpGet Commented Jul 11, 2016 at 13:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.