简体   繁体   中英

Android Emulator not connecting with localhost Apache

I am developing an app in Android, and the emulator is not connecting to my localhost. I have researched the issue and found some ideas but nothing seems to be working.

Below is the code i have been using:,

HttpClient httpclient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://10.0.2.2/YES_BUTTON.php");
httpclient.execute(httpPost);

I have also tried a connection using "http://10.0.2.2:3128/YES_BUTTON.php";

The code would run a php file, but nothing happens, I have also checked the server access log and no connection was ever made with the Apache server from the emulator.

This is my first time building an app, and was wondering if there was something I haven't done, do I need to map the emulator port with the 3128 port on Apache, disable the firewall? I am developing the app on a laptop,with the Apache Server on the laptop also, so everything is being done on the same machine. Is there anything I havent done that needs to be done?

I bet you forgot to add the INTERNET permission :)

INTERNET

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