Android
Network Connectivity
Simulation
Android Development
Troubleshooting

Simulate low network connectivity for Android

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Testing an Android app only on fast local Wi-Fi hides a large class of bugs. To understand how the app behaves for real users, you should simulate slow bandwidth, high latency, packet loss, and temporary disconnects during development and QA. The goal is not only to slow requests down, but to see whether the app stays understandable and recoverable under bad conditions.

Use the Android Emulator First

The Android Emulator has built-in controls for network speed and latency, which makes it the fastest place to start.

You can launch an emulator with slower settings directly from the command line:

bash
emulator -avd Pixel_8_API_35 -netspeed edge -netdelay gprs

Those options simulate slower bandwidth and increased latency without changing your application code.

If you prefer the emulator UI, the extended controls also expose network controls where you can choose different speed and delay profiles.

What to Test Under Poor Connectivity

Low connectivity is not only about download speed. You should test:

  • high latency before the first byte arrives
  • interrupted requests during loading
  • uploads on unstable links
  • retry logic under repeated failures
  • image-heavy screens on narrow bandwidth
  • UI feedback during long waits

A screen that eventually works can still be broken if the user sees only a frozen spinner and no useful message.

Build the UI for Failure States

Network simulation exposes assumptions in the client code. For example, if you fetch data with Retrofit or another HTTP client, the UI should show loading and failure states explicitly.

kotlin
1lifecycleScope.launch {
2    progressBar.isVisible = true
3    statusText.text = "Loading..."
4
5    try {
6        val result = api.fetchProfile()
7        statusText.text = result.name
8    } catch (e: Exception) {
9        statusText.text = "Network error. Please try again."
10    } finally {
11        progressBar.isVisible = false
12    }
13}

Without states like these, low-connectivity testing often reveals blank screens, frozen buttons, or duplicate requests triggered by impatient users.

Real Device Testing Still Matters

The emulator is convenient, but a physical device is still important when network behavior matters to the product. Real devices let you test radio transitions, hotspot behavior, background restrictions, and OEM-specific networking quirks.

Common real-device approaches include:

  • using a throttled hotspot
  • routing traffic through a proxy that can shape bandwidth and latency
  • limiting the host network path that the device uses

The specific tool varies, but the principle is the same: put a controlled bottleneck between the app and the internet.

Configure Timeouts Deliberately

Slow links often expose timeout and cancellation bugs rather than only rendering bugs. Configure network timeouts intentionally and verify that the UI recovers when they are reached.

Example with OkHttp:

kotlin
1val client = OkHttpClient.Builder()
2    .connectTimeout(10, TimeUnit.SECONDS)
3    .readTimeout(20, TimeUnit.SECONDS)
4    .writeTimeout(20, TimeUnit.SECONDS)
5    .build()

After setting those values, test whether the app shows a useful message and allows retry instead of trapping the user in an endless loading state.

Check Caching and Offline Behavior

Low-connectivity testing is also a good way to validate caching. If the network disappears after a successful sync, the app should still behave predictably.

Even a simple cache can improve resilience:

kotlin
1val cachedName = preferences.getString("profile_name", null)
2if (cachedName != null) {
3    statusText.text = cachedName
4}

That is not a full offline architecture, but it keeps degraded connectivity from becoming a total failure.

Common Pitfalls

The most common mistake is testing only bandwidth and ignoring latency. Many apps feel broken because of slow round trips, not only because of low throughput.

Another mistake is relying only on the emulator. Emulator testing is essential, but some failures appear only on real hardware under actual radio changes and background behavior.

People also focus only on network calls and forget the UI contract. Users need visible loading, retry, timeout, and offline states.

Finally, do not wait until late QA to test bad connectivity. Network resilience is easier to design early than to retrofit after the UI and request flow are already fixed.

Summary

  • Use the Android Emulator to simulate slower bandwidth and higher latency quickly.
  • Test latency, disconnects, uploads, retries, and timeout behavior, not only download speed.
  • Add clear loading and error states so degraded networks remain understandable.
  • Validate timeout and caching behavior under realistic slow conditions.
  • Include real-device testing when network behavior is important to the app experience.

Course illustration
Course illustration

All Rights Reserved.