How to put an AVD (emulator) into OFFLINE mode?

I would like to test the behavior of my application when the user is in a no-signal zone or when his phone is in flight mode.

-> How do I put an Android Virtual Device into offline mode (where no connection to the internet is possible) ?

  • scrollingCache?
  • ScrollView Inside ScrollView
  • How can i dim the background when Bottomsheet is displayed, without using Dialog?
  • Orientation change in Honeycomb
  • Android soft keyboard hides button
  • Override layout xml from android framework
  • I have tried the following:

    • Activating flight mode via the AVD settings: surprisingly, this does NOT work (browsing the internet is still possible in flight mode!)

    • Disabling the network connection on my PC: this obviously works, but is not satisfactory as I need Internet when I am testing my app

    Related posts:

    What is the difference between Android margin start/end and right/left?
    How to know which view inside a specific ListView item that was clicked
    what is the difference between ACTION_SENDTO and ACTION_VIEW when sending sms?
    Create a Bitmap/Drawable from file path
    PAC support disabled because there is no system implementation
    Practical Difference Between position and row id in onListItemClick()
  • Android Fastboot devices not returning device
  • Using the Android InApp Billing V3 example. Hit Buy, Back Button, and buy again causes error
  • Can we delete an SMS in Android before it reaches the inbox?
  • NoClassDefFoundError on external library project for Android
  • How to “wait” a Thread in Android
  • Convert string to JSON array
  • 10 Solutions collect form web for “How to put an AVD (emulator) into OFFLINE mode?”

    I’m seeing all the same problems. DDMS doesn’t fully kill it. Neither does F8. And neither does turning on airplane mode inside the emulator. We should all probably star this issue someone logged in 2009.


    $ adb shell svc wifi enable
    $ adb shell svc wifi disable


    $ adb shell svc data enable
    $ adb shell svc data disable

    I found a working solution. Tested on Android 6.0 an 7.0 emulators, but should work on others.

    Network down:

    adb shell ifconfig eth0 down

    Network up:

    adb shell ifconfig eth0 up

    If you get a “Permission denied” error, restart adb daemon as root:

    adb root

    and try again.

    You should just press F8 in emulator window, it toggle off cell networking according to: But I test it and it is not working too! There is only message that there is no internet connection but it actually works…

    All I do is go into the Window menu, select ‘open perspective->other’ open the DDMS perspective. Inside the DDMS perspective you have an ‘Emulator Control’ view where you can adjust latency, roaming, you can give it different telephone and data states. So following this procedure to get the Emulator view, you then go to ‘Data’ drop down and select the ‘Denied’ option.

    I found in my ‘Emulator Control’ view when I adjust Voice and Data to “unregistered” not “denied” works for me. Now I finally got the AVD offline for network while I can still post this answer.

    Instead of using Airplane mode in the Android emulator ( which does not work too well ) , switch off the network connectivity to your system while testing. That is , switch of the Ethernet connectivity or Wi-fi . Worked well for me.

    Old questions, but I found a solution:

    1. Open a command line: CTRL+R > cmd
    2. Change to android tools folder

      cd C:\Program Files\Android\android-sdk\tools

    3. Run the emulator with a false DNS server. Change 2.3.3 to the the name of your AVD. The @ makes it start:

      emulator.exe @2.3.3 -dns-server

    Check the manual for more command line options.

    One comment of the issue mentioned by James Koch says that there is an workaround:

    Comment 15 by, Jul 8, 2011
    Finally found a work around for this issue:
    telnet localhost 5554    // Connects to the emulator
    qemu monitor             // Enter in the QEmu functionalities
    info network             // List the network adapter "user.0" is usually the name
    set_link user.0 down     // Shut the network down
    set_link user.0 up       // Re-enable networking


    Comment 16 by, Sep 6, 2011
    This work around doesn't work for me on MacOS 10.7.1 and SDK rev 12 (with platform 2.2, 2.1 and 2.3.3)
    ... ...
    qemu monitor
    KO: internal error: could not detach from console !

    -> Same for me on Windows Vista, SDK rev 19 and platform 10 (2.3.3)

    But perhaps that’s usable for somebody…

    Finally, how about this approach.

    android-sdks/tools/emulator -avd [AVD name goes here] -qemu -net nic,vlan=0 -net user,vlan=1

    Actually, this is a trick because the following crashes my emulator:

    android-sdks/tools/emulator -avd [AVD name goes here] -qemu -net none

    Tested with Android emulator V21.0 on Debian.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.