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) ?

  • How to make TextWatcher wait for some time before doing some action
  • Android MediaPlayer warning: Should have subtitle controller already set
  • Alternative to zxing QR reader library for Java/Android?
  • Intent to start activity - but don't bring to front
  • Android (Java) HttpURLConnection silent retry on 'read' timeout
  • 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:

    Mailto from preferences xml possible?
    How is the “Active Installs” count/percentage in the Android “Develope...
    Follow user location on React Native AirBnb's MapView
    The apk must be signed with the same certificates as the previous version
    Click on the top half of a button - doesn't work?
    Turn (rotate)marker position based on direction over the route
  • How to cancel Handler in code?
  • Under what circumstances will Android's terminate my app?
  • Android ICS emulator camera
  • Android: detect brightness (amount of light) in phone's surroundings using the camera?
  • Android Unable to remove the color at the top and bottom
  • My first app. Error: Invalid start tag LinearLayout. Why?
  • 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.