In andriod I am accessing my local address (Ex:'http:/192.168.173.1/something'). I want to read the content,but it is showing the exception os.Network on main thread Exception.I want to work on my website only, but this is the problem Can anybody solve my problem and help me...
Asked
Active
Viewed 148 times
0
-
This exception only comes in my emulator, but in my phone I am not getting any exception..... – YniA Jan 24 '14 at 04:12
-
That's most likely because your phone is running Android 2.3 or older whereas the emulator is running 4.0 or newer. – A--C Jan 24 '14 at 20:33
2 Answers
0
You need to start a thread in order to make network requests. You cant make any http request in android on main UI thread. try using asyntask

Pulkit Sethi
- 1,325
- 1
- 14
- 22
-
This exception only comes in my emulator, but in my phone I am not getting any exception – YniA Jan 24 '14 at 04:13
-
This is because this was added in later version of Android. You're phones would have different Android version than emulator – Pulkit Sethi Jan 26 '14 at 21:28