30

I'm building an app that uses AsyncTask to display a progress bar when it's performing network operation (Google translate). However, the problem is that I can't tell if it's working since the network is too fast and it finishes running the operation as soon as I start it. So is there a way to simulate a slow network so that I can tell if the progress bar will actually run (visible) when it's waiting for the operation to be completed? I have come across network options when creating an Android emulator. However, there are so many abbreviations that I still have trouble understanding what indicates slow network connection and I'm still not sure if that is how I should set a slow network connection.

Thanks in advance!

Charles Li
  • 1,835
  • 3
  • 24
  • 40

4 Answers4

51

The emulator lets you simulate various network conditions. You can approximate the network speed for different network protocols, or you can specify Full, which transfers data as quickly as your computer allows.

Specifying a network protocol is always slower than Full. You can also specify the voice and data network status, such as roaming. The defaults are set in the AVD.

Select a Network type:

  • GSM - Global System for Mobile Communications
  • HSCSD - High-Speed Circuit-Switched Data
  • GPRS - Generic Packet Radio Service
  • EDGE - Enhanced Data rates for GSM Evolution
  • UMTS - Universal Mobile Telecommunications System
  • HSPDA - High-Speed Downlink Packet Access
  • Full (default)

Speeds for reference in increasing kbps:

                        UP       DOWN
                  -------- ----------
gsm   GSM/CSD         14.4       14.4
hscsd HSCSD           14.4       57.6
gprs  GPRS            28.8       57.6
umts  UMTS/3G        384.0      384.0
edge  EDGE/EGPRS     473.6      473.6
hsdpa HSDPA         5760.0   13,980.0
lte   LTE         58,000.0  173,000.0
evdo  EVDO        75,000.0  280,000.0
full  No limit           ∞          ∞

Select a Voice status, Data status, or both:

  • Home (default)
  • Roaming
  • Searching
  • Denied (emergency calls only)
  • Unregistered (off)

For more information see https://developer.android.com/studio/run/emulator.html#extended

Joshua Pinter
  • 45,245
  • 23
  • 243
  • 245
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • Thanks! I was actually on this page earlier, but even after I searched up the network types I still don't know which one is the slowest. As I test it out, it still seems pretty quick. – Charles Li Jul 01 '16 at 14:09
  • 3
    FYI, the options on my emulators were not the same as what's listed here. I get `GSM HSCSD GPRS EDGE UMTS HSDPA 4G` And the weirdest part is that they are all VERY slow. The fastest one that wasn't 4G/LTE was something like 78 kbps, which is insanely slow. There was no "3G" option. So this is great for testing very slow connections but I ended up tethering my iPhone, limiting my cellular connection to 3G and using that to test instead. I wish they added more speeds and that they specified the exact speed being achieved for each instead of making us look it up. – Joshua Pinter Jul 05 '18 at 20:52
2

With telnet on the command line you can connect to your emulator and change the device's network speed.

telnet localhost <<port of device>>
network speed <<network speed, ex: edge, full>>

You can get the port for the device from the top of the window of the emulator.

You can use any of the speeds in the android docs here. Id recommend edge for slow speeds

If you are on windows you will have to setup telnet, you can find directions to do so in this SO post.

Community
  • 1
  • 1
Dr. Nitpick
  • 1,662
  • 1
  • 12
  • 16
  • Thanks! So I run those commands after I launch my app in the emulator? And for the network speed, what parameters should I give it to make it slow? Thanks! – Charles Li Jul 01 '16 at 14:15
  • Yup, just run these two commands in the command line once your emulator is running (you don't need your app to be up). To make it slow I recommend using "edge" as the speed. It looks like the link to the speeds is not properly formatted so Ill fix that – Dr. Nitpick Jul 01 '16 at 16:48
2

In OS X you can use Network Link Conditioner, very useful. Here is a link how to use it and how to install. It will affect all programs using network.

http://nshipster.com/network-link-conditioner/ enter image description here

Also you can send all traffic to proxy and use throttling. I used Charles (Commercial, 30 days free trial) https://www.charlesproxy.com/

Anessence
  • 589
  • 5
  • 20
  • Thanks! Does it also work on Android emulators? or is it fine since I'm running my Android emulator on a mac? – Charles Li Jul 01 '16 at 14:12
  • It emulate bad network for everything that is running in OSX. The same for proxy. – Anessence Jul 01 '16 at 17:32
  • @CharlesLi Note, if you're connecting your emulator to a local server running on your Mac, I don't think this will throttle since it's happening locally. For example, I'm connecting an emulator to a rails app running on locally on my Mac so it bypasses this. I think. – Joshua Pinter Jul 04 '18 at 19:15
  • FYI, this Network Link Conditioner only applies to iOS emulators running, not the host machine's network connection. I was trying to use this to limit my Mac's network connection so the Android emulator can be throttle through my Mac's connection. No luck. – Joshua Pinter Jul 04 '18 at 20:08
  • Network Link Conditioner applies to macOS, not only iOS simulator. So everything which is running on OS should be throttled. I had no issues with that. – Anessence Jul 23 '18 at 18:01
  • This does not affect Android emulator – Vahid Amiri Oct 09 '22 at 18:27
2

Within the emulator app, you can change the network settings by clicking the three dots on the side:

emulator settings

Then choose "Cellular" and you can see the network settings.

network settings

Alexander Wu
  • 433
  • 4
  • 8