[英]error “connection refused” when trying to access to a php page stored on localhost from android app
i am trying to make my first demo app which communicates with remote server. 我正在尝试制作与远程服务器通信的第一个演示应用程序。 i have a php project setup on localhost and trying a access a php page from android app.
我在本地主机上设置了一个php项目,并尝试从android应用访问一个php页面。 when i try to run and access the page i get the error "connection refused" by the app and it stops running.
当我尝试运行并访问该页面时,该应用显示“连接被拒绝”错误,它停止运行。 to access the page i am passing "my_ip_address/folder_name/file_name.php" as url .
访问页面,我将“ my_ip_address / folder_name / file_name.php”作为url传递。 when i give the same link in browser i get the desired data but not in case when i try to connect it through mobile app.
当我在浏览器中提供相同的链接时,我会获取所需的数据,但当我尝试通过移动应用程序将其连接时却无法获取。 i am running the app on my own android mobile .
我在自己的android手机上运行该应用程序。
i have found some same questions but unfortunately because of low points couldn't paste my question to that thread. 我发现了一些相同的问题,但是不幸的是,由于低点无法将我的问题粘贴到该线程上。 I also tried out giving the url as "10.0.2.2:8080/folder_name/file_name.php" but it didn't help.
我还尝试将URL设置为“ 10.0.2.2:8080/folder_name/file_name.php”,但这没有帮助。 i have also updated the manifest file to access the internet.
我还更新了清单文件以访问Internet。 the other solution i found is "my_ip/folder_name/file_name.php" which i am already trying.
我发现的另一个解决方案是我已经尝试过的“ my_ip / folder_name / file_name.php”。 it wll be great if anyone could help me here.
如果有人可以在这里帮助我,那将是很棒的。
Thanks for your help in advance ! 预先感谢您的帮助!
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET" />
http://10.0.2.2/folder_name/file_name.php
http://10.0.2.2/folder_name/file_name.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.