-4

Basically, the only error I am getting when I try to request a http connection is,

Error in http connection !! android.os.NetworkOnMainThreadException

I am trying to connect to database in my Wamp server using an android emulator and this is part of the code I used,

   response = CustomHttpClient.executeHttpPost(
   "http://152.226.152.96:89/MPSIP/jsontestscript.php",
   postParameters);

I also tried using localhost instead of my IP but I will get the exact same error.

I would like to know how I may establish a http connection with my wampserver. Am I missing out on a step or am I going about it all wrong.

If it helps, I used the guide from,

Link to example used here

user2326860
  • 1
  • 1
  • 4
  • 12
user2330725
  • 31
  • 1
  • 4
  • Check this thread http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception?rq=1 – Ajay S Apr 29 '13 at 05:25
  • And what does "network on main thread" tell you? What could it mean? And what happens if you search for that on the web? – class stacker Apr 29 '13 at 05:26
  • Try this google search and click on the first link! https://www.google.co.il/search?q=android.os.NetworkOnMainThreadException&aq=f&oq=android.os.NetworkOnMainThreadException&aqs=chrome.0.57j61l2.144j0&sourceid=chrome&ie=UTF-8 – tbkn23 Apr 29 '13 at 05:28

1 Answers1

-1

This is probably because you are doing network operation on main/UI thread. Read about AsyncTask and Thread

Read HERE.

P.S: Do some google search before posting questions on SO.

Gaurav Arora
  • 17,124
  • 5
  • 33
  • 44