How do I disable the Internet connection in Android Emulator?

后端 未结 11 1651
执念已碎
执念已碎 2020-12-29 01:33

I am trying to check Internet connectivity on Android using the following method. I have a Wi-Fi connection.

private boolean checkInternetConnection() {
             


        
相关标签:
11条回答
  • 2020-12-29 01:54

    From Eclipse

    To disable the Internet connection, go to Eclipse and do

    menu Window -> Show view -> Other -> Android -> Devices
    

    Now select your running emulator and again go to:

    menu Window -> Show View -> Other -> Android -> Emulator Control
    

    Now in that... set Data to Unregister from Home.

    From Device and Emulator

    On the device or in the emulator, go to:

    Setting -> Wireless & networks -> Airplane Mode -> OK
    
    0 讨论(0)
  • 2020-12-29 01:56

    telnet localhost 5554 (or Android emulator number)

    Internet enabled:

    gsm data home
    

    Internet disabled:

    gsm data unregistered
    

    You can use my library, available on http://www.cristianmarquez.com.ar.

    0 讨论(0)
  • 2020-12-29 01:57

    Steps to disable Internet in the Android emulator:

    1. First install the application into the emulator
    2. Long press the power button of your emulator
    3. Choose Airplane Mode

    Now your emulator won't accept an Internet connection.

    Note: Here after Airplan mode, you can't install and run your app in the emulator, so before putint it into Airplane mode, run your app in your emulator.

    For changing to normal once again, long press emulator and choose the same option.

    0 讨论(0)
  • 2020-12-29 02:05

    Try the below command

    WIFI:
    $ adb shell svc wifi enable
    $ adb shell svc wifi disable
    MOBILE DATA:
    $ adb shell svc data enable
    $ adb shell svc data disable
    
    0 讨论(0)
  • 2020-12-29 02:05

    There are many methods. I am explaining two methods here.

    1. Just hit the F8 key to enable or disable the Internet connection.
    2. Just start your emulator, hold on the power button and then select:

    Airplane mode Off

    It will disconnect your emulator from the Internet. If you want to connect again, just hold on the power button again and select:

    Airplane Mode ON

    And your emulator's Internet connection will start working!

    0 讨论(0)
提交回复
热议问题