Android emulator not connecting to localhost Apache

I am developing an application on Android, and the emulator does not connect to my local host. I investigated the problem and found some ideas, but nothing works.

Below is the code I used :,

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

I also tried connecting using "http://10.0.2.2lla128/YES_BUTTON.php";

The php file will work in the code, but nothing happens, I also checked the server access log and there was no connection to the Apache server from the emulator.

This is my first time I am creating an application, and was wondering if there was something that I hadn’t done yet, do I need to map the emulator port to port 3128 on Apache, disable the firewall? I am developing an application on a laptop, with Apache Server on a laptop, so that everything is done on one machine. Is there anything I have done that needs to be done?

+3
source share
1 answer

I bet you forgot to add the INTERNET permission :)

INTERNET

+2
source

Source: https://habr.com/ru/post/1793674/


All Articles