Oh ok so on the android emulator I am trying to parse Json and I am using Visual Studio C# as the web service in between. Each time I fire of the emulator it returns Null, how can I fix this? I have uploaded that Json file to my website and it works correctly but can't see to make it work on the emulator. The file is called tryjson.json and I can get to it on the internet by using http://localhost:62446/tryjson and my website http://www.website.com/tryjson on the emulator I am trying http://10.0.2.2:62446/tryjson and http://10.0.2.2/tryjson yet they return null what can possibly be wrong? I know that the Json is correct because if I do http://www.website.com/tryjson in the emulator URL it comes back. The issue is obviously something with the localhost connection but I do not know what.
The alias " http://10.0.2.2:62446/tryjson " should have worked, since the documentation says that for localhost requests you should use this adress ( http://developer.android.com/tools/devices/emulator.html ).
But try using your ip adress. If you use windows, open cmd and type
ipconfig
you should see your ip adress, something like 192.168.X.XXX.
Use it in the url your app is requesting.
Are you running your own webserver? Make sure the webserver is launched with 0.0.0.0
as the host (instead of localhost
).
Often web servers default to localhost
which means the server will only listen to requests on 127.0.0.1
. Using 0.0.0.0
will make the server listen on any IP.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.