Android emulator browser access to the Internet and the local web

Source: Internet
Author: User
Tags web services java web tomcat

In this article we talk about configuring Adroid environment variables (such as adding D:ANDROID-SDK-WINDOWS-1.0_R1 ools to the system variable path) in a Windows environment, and entering at the command line window:

Emulator

After starting the Android emulator, enter:

ADB shell

Enter adb shell mode:

Write the network connection Agent settings to the configuration database, if your Internet proxy IP is 10.193.xx.xx:
Sqlite3/data/data/com.android.providers.settings/databases/settings.db INSERT into System VALUES (99,http_proxy, 10.193.xx.xx:1080) "
Check to see if the system settings have been successfully changed:

Sqlite3/data/data/com.android.providers.settings/databases/settings.db "SELECT * from System"


The result should be: 99|http_proxy|10.193.xx.xx:1080

Restart the emulator, you should be able to use browser on the Internet.

Delete the configuration information method you just wrote:
Sqlite3/data/data/com.android.providers.settings/databases/settings.db "DELETE from System WHERE _id=99"


Android emulator access to local Web apps

One morning I wanted to get the Android emulator to access the Web apps, but it was never possible to get overwhelmed.

Open Control Panel-select programs and Features-click on the left to turn on or off Windows features-then choose CGI, and so on ... Tried for a long time or not.

Later in the search for the time to see is a piece of information introduced:

How do I access a local Web application on the Android emulator? For example, start a Tomcat service on your development machine, then open the browser on your computer, and by default you can access Tomcat's home page by typing http://localhost:8080/, so if we want to access the Android emulator, can we? The answer is yes, but the URL of the visit will change. Please continue to look down.

In the general development of Java Web applications, We usually use localhost or 127.0 0.1来 to access the local Web services, but if we use the same address in the Android emulator, the Android emulator will not be able to access our services properly. We can understand this: Android is the bottom of Linux kernel, including Android itself is an operating system, so The localhost or 127.0.0.1 that we entered in the simulator's browser is represented by the Android emulator (Android virtual machine), not your computer, do you understand? This is why you will report "Web page not available" When you use localhost in the emulator.

So how do you get access to Web apps on your local computer? In Android, the address of our local computer is mapped to 10.0.2.2, so you can access the Web resources on the local computer on the emulator simply by replacing the original localhost or 127.0.0.1 with 10.0.2.2.

So let's start Tomcat on the computer, then run the Android emulator, open the browser on the emulator, and then visit: http://10.0.2.2:8888 have you seen that cute tomcat cat? The access screenshot is shown in the following figure. (Note: On my computer, the Tomcat service uses a port of 8888, the default is 8080)

Figure:


Try it out, it's good. O (∩_∩) o~ hehe

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.