-1

I got a website which just response with "true" With my app I need to open that website and just get back that response. I tried for a few hours to do that with some http GET methods but nothing worked (not even plain copying of tutorials of that).

I just need to get the reponse of the website (in this case the word "true") and put it into a textview. But how to do that? I always fail at the line:

HttpResponse response = client.execute(request);

And I get errors like

 Error in http connection android.os.NetworkOnMainThreadException

I tried it on Emulator and 3 Smartphones which are in the wlan and have internet access. The app has also permissions to access internet and network.

I need some help. Thank you!

AlcuPala
  • 21
  • 2

2 Answers2

0

You can use a library to make things easier. Android Async Http Client works well.

Hugo Zapata
  • 4,314
  • 5
  • 29
  • 32
0

Welcome to StackOverflow.

Your problem here is that you are trying to do some network request inside the UI thread of your application; which is protected by the framework.

If you are very new to Android, I suggest you to read the following article about AsyncTask : Processes and Threads

pdegand59
  • 12,776
  • 8
  • 51
  • 58