Android connection to localhost

前端 未结 9 494
囚心锁ツ
囚心锁ツ 2020-12-01 11:23

I\'m trying to connect my android application to a local host url thanks to wamp server but it doesn\'t work. My goal here, is to fetch json data and parse these data. For m

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-01 11:35

    If you try to connect to "localhost", it will resolve to the Android device, not to your own localhost (unless you are running within the emulator). What I recommend for development is to add an overflow menu in the action bar that has an entry named "Settings" that provides a Settings activity for specifying application settings, and to have a "Developer options" entry in "Settings" that lets you specify a custom server address to use. During development, you can use this option to enter a custom server address for your app. (You will need a real server address that is actually reachable over the Internet rather than using localhost for this).

提交回复
热议问题