I need to test app for work with slow internet connection. How to simulate slow internet connection on Android emulator?
问题:
回答1:
For Android Studio projects you can do the following:
If you need to change net speed temporarily, then on an emulator toolbar, click three dots (settings), go to Cellular tab and configure the network speed there. You need to have a recent Android Tools.
If you want to set this speed permanently for some emulator image:
- Open menu Tools -> Android -> AVD Manager
- Select/create your emulator avd image, click Edit
- Click Show Advanced Settings button
- Set the desired net speed
- Re-launch the emulator
OLD ANSWER (obsolete)
If you are working in Eclipse, go to Run->Run Configurations, select your run configuration and then go to "Target" Tab. There you will find a "Network Speed" combobox (under the "Emulator Launch Parameters" section).
If you are running emulator from command line, then you can use "-netspeed" cmd line parameter (run emulator -help-netspeed for overview of possible options)
回答2:
Easiest way to tweak things while emulator is still up is to use the emulator console. Just use telnet or netcat (interactively, you can just "telnet localhost 5554" and type "help" -- below examples show how to script it:
$ echo "network speed 100 100" | nc localhost 5554
$ echo "network status" | nc localhost 5554
Current network status:
download speed: 100000 bits/s (12.2 KB/s)
upload speed: 100000 bits/s (12.2 KB/s)
minimum latency: 0 ms
maximum latency: 0 ms
You can also set the delay/latency:
$ echo "network delay gprs" | nc localhost 5554
$ echo "network status" | nc localhost 5554
Current network status:
download speed: 100000 bits/s (12.2 KB/s)
upload speed: 100000 bits/s (12.2 KB/s)
minimum latency: 150 ms
maximum latency: 550 ms
Just makes it easier to do things at runtime and test various scenarios (via automation, manual testing, etc).
回答3:
In Eclipse : Run -> Run Configuratrions -> click!
Select Tab Target. click!
Then there is an option Network Speed!
Set it to emulate whatever you want. :)
回答4:
Run->Run Configurations: there you can find Emulator Launch Parameters where you can set the internet speed