Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

avd

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

like image 796
Sébastien Avatar asked Oct 24 '10 14:10

Sébastien


People also ask

How do I turn my emulator online?

1. just click on "About the emulator" -> "Build Number" about 5-7 times. 2. This will open "developers options", go back and click on it and enable "USB debugging" to bring it online.

How do I know if my emulator is online?

The way that Android detects emulators is by scanning ports starting at port 5555. The number you see in the adb devices list (in your case 5554) will be one less than the port that adb is finding open. You probably have a process running that is listening on port 5555.

Can turn off WIFI Android Emulator?

You can disable the Internet connection by pressing F8 in any Android emulator. It is a toggle button, so if it doesn't have Internet connection then it will start the Internet connection and if it already has an Internet connection then it will dis-connect it.


3 Answers

WIFI:

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

MOBILE DATA:

$ adb shell svc data enable
$ adb shell svc data disable
like image 107
Marco C. Avatar answered Oct 20 '22 16:10

Marco C.


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.

like image 14
James Koch Avatar answered Oct 20 '22 16:10

James Koch


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.

like image 7
noamtm Avatar answered Oct 20 '22 17:10

noamtm