无法通过Android应用访问笔记本电脑的本地主机 [英] Can't access my laptop's localhost through an Android app

查看:69
本文介绍了无法通过Android应用访问笔记本电脑的本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在发布此消息之前,我进行了一项研究,发现更准确的解决方案无效:

So I did a research before posting this and the solutions I found didn't work, more precisely:

-连接到笔记本电脑的IPv4 192.168.XXX.XXX-无效

-Connecting to my laptop's IPv4 192.168.XXX.XXX - didn't work

-连接到10.0.2.2(加上端口)-不起作用

-Conecting to 10.0.2.2 (plus the port) - didn't work

我需要测试使用Django Rest框架构建的API,以便获得返回的json,但是我无法通过正在构建的Android应用程序进行访问(我正在使用真实设备进行测试,而不是模拟器). Internet权限设置在Manifest上,我可以正常访问远程网站.只是无法到达我的笔记本电脑的本地主机(它们在同一网络中)

I need to test an API i built using Django Rest framework so I can get the json it returns, but i cant access through an Android app i'm building (I'm testing with a real device, not an emulator). Internet permissions are set on Manifest and i can access remote websites normally. Just can't reach my laptop's localhost(they are in the same network)

我对Android,Python和Django还是很陌生(用于构建Django的Rest Framework API).

I'm pretty new to Android and Python and Django as well (used to built Django's Rest Framework API).

我使用localhost:8000/snippets.json或类似的方式在笔记本电脑上进行连接.

I use localhost:8000/snippets.json or smth like this to connect on my laptop.

PS:我了解了一些有关XAMP服务器的信息...在这种情况下需要它吗?

PS: I read something about XAMP server... do I need it in this case?

预先感谢

推荐答案

您是否已启动服务器?

python manage.py runserver 0.0.0.0:8000

然后,尝试连接到192.168.XXX.XXX:8000

Then, try to connect to 192.168.XXX.XXX:8000

这篇关于无法通过Android应用访问笔记本电脑的本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆