简体   繁体   中英

How to send http request to android emulator

i've created small http server in android , code is from this link just copy pasted in eclipse. http://www.java2s.com/Open-Source/Android/Samples/android-jp-kobe/net/cattaka/teamredwhite/HTTPServer.java.htm

How do i send simple request from browser to server now? I would like something like this 127.0.0.1:12345?x=100&y=50 for example. Browsers always says that he didnt make connection with that url. In on create of main activity i just created a server with port 12345 and run .listen()

127.0.0.1 on is your local computer, not the emulator.

The emulator has its own network address space :

You're most likely looking for 10.0.2.15 , "the emulated device's own network/ethernet interface", eg http://10.0.2.15:12345?x=100&y=50 .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM