2

I read a number of examples through this website, but none of them worked on emulator. Sharing the posts I read:

Just to clarify, when I turn off the PC network connection, the emulator still returns true.

Community
  • 1
  • 1
nenito
  • 1,214
  • 6
  • 19
  • 33

1 Answers1

1

When you turn off the PC's network connection, the emulator still has one - however it goes no further than the PC.

If you want to determine if it's possible to reach the outside world, you will probably have to try contacting something on the public Internet and seeing that you can both resolve the domain name and actually get traffic there and back.

I can't help wondering why this is important. The emulator is only for testing. If you want to simulate a lack of network connection on the emulator, put it in airplane mode or change its settings. Pulling the PC network connection is comparable to some sort of upstream failure in the mobile provider's infrastructure, not comparable to a device which has neither a mobile nor wifi connection.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117