Friday, April 27, 2012

Android - Emulator internet access


I've been using this method to gain access to internet from my Android emulator emulator -http-proxy <<proxy-name>> -avd <<avd_name>>



It works but is that the best way to do it? It just doesn't feel right that I need to open the emulator from command line and can't just do it from Eclipse or something.



Can't seem to find an internet option on the "AVD Manager" either.



Thanks,



Tee


Source: Tips4all

7 comments:

  1. You could also try explicitly specifying DNS server settings, this worked for me.

    In Eclipse:

    Window>Preferences>Android>Launch

    Default emulator options: -dns-server 8.8.8.8,8.8.4.4

    ReplyDelete
  2. By default, you should be able to toggle the Internet access to your emulator with F8 (on Windows) and Fn + F8 (on Mac OS X) - I think F8 also works for Linux, but I'm not 100% sure.

    With this shortcut, you get the ACTION_BACKGROUND_DATA_SETTING_CHANGED dispatched.

    Hope that helps.

    ReplyDelete
  3. -http-proxy can be set in eclipse this way:


    Menu Window
    Submenu Preferences
    In Preferences Dialog
    Click Android in left part
    Click Launch
    Near Default Emulator Options: input ur -http-proxy

    ReplyDelete
  4. Add GSM Modem Support while creating AVD in your virtual devices from Android SDK and AVD Manager...

    ReplyDelete
  5. It was setting the DNS that did the trick for me. If you are using the Eclipse or Netbeans plugins, you can set it through Default Emulator options, or Emulator Options respectively. You can also use set it from the command line if you start your emulator from CLI. In all cases, the option is "-dns-server x.x.x.x,x.x.x.x" without the quotes. There is no option in the ADB gui to permanently associate the option with your virtual device.

    ReplyDelete
  6. On a slightly different note, I had to make a virtual device without GSM Modem Support so that the internet on my emulator would work.

    ReplyDelete
  7. for the records since this is an old post and since nobody mentioned it, check if you forgot (as I did) to set the android.permission.INTERNET flag in AndroidManifest.xml as, i.e.:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android.webviewdemo">
    <uses-permission android:name="android.permission.INTERNET"/>
    <application android:icon="@drawable/icon">
    <activity android:name=".WebViewDemo" android:label="@string/app_name">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    </application>
    </manifest>

    ReplyDelete