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

Viewed 20805

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

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

11 Answers

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.

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.

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.

I found that the answer from @Marco C. worked, but I also found that my AVD settings allowed for doing this very easily as well.

In the sidebar, click the triple dot icon all the way at the bottom:

enter image description here

Then, adjust your cellular settings, "Signal Strength" and "Data Status" to "none" and "denied" respectively, as shown in this image:

enter image description here

Related