How can I access a local web application on the android simulator?

Source: Internet
Author: User

Generally, start a tomcat service on your development machine, and then open the browser on your computer. By default, enter http: // localhost: 8080/can be used to access Tomcat's home page. If we want to access Tomcat on the android simulator, can we? The answer is yes, but the access URL will change. Why? Continue.
In general Java WebProgramDuring development, we usually use localhost or 127.0.0.1 to access the Web service of the local machine. However, if we use the same address in the android simulator, the android simulator cannot access our services normally. Why? We can understand that the underlying layer of Android is Linux kernel, and Android itself is an operating system. Therefore, at this time, the input localhost or 127.0.0.1 in the simulator browser represents the android simulator (Android Virtual Machine) instead of your computer. Do you understand? This is why "Web" is reported when you use localhost in the simulator.
Page not available.

How can we access web applications on a local computer? In Android, the address of our local computer is mapped to 10.0.2.2. Therefore, you only need to replace the original localhost or 127.0.0.1 with 10.0.2.2, then you can access the Web Resources on the local computer on the simulator.

Next we will start Tomcat on the computer, run the android simulator, open the browser on the simulator, and then access: http: // 10.0.2.2: 8888 have you seen the cute tomcat cat? See. (Note: on my computer, the Tomcat service uses port 8888. The default value is 8080)

Figure:

Trial, very useful. O (distinct _ distinct) O ~ Haha

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.