2017-07-30 23 views

回答

1

所以我不知道你的本地主機鏈接,但你可以試試這個:

http://localhost //This refers to the device where code is running 

http://127.0.0.1 //This refers to the device where code is running 

10.0.2.2 //This refers to the computer 
0

你需要在你的android應用中設置url來引用你的本地機器的IP地址。

例如,您的服務器在端口5000上運行,因此您可以使用http://localhost:5000來調用您的API。要從另一臺機器(作爲您的android手機)調用它,您需要呼叫http:// {YOUR_IP}:5000

+1

兩臺機器必須位於同一個網絡中。 :) – RamKumar

+0

正是!感謝您的補充。 –

+0

嗨,thnx回覆。 當我嘗試從我的PC訪問http:// localhost:5000時,它給了我JSON響應,但是當我嘗試從我的Android瀏覽器(它連接到同一網絡)訪問http:// :5000時,我「太久迴應」錯誤。 我是否必須配置防火牆或什麼?如果是的話,你能告訴我如何? – realpac

相關問題