1

I run my app with android emulator. In my app I am using:

        markTextWithArrow("signal strength:" + networkCapabilities.getSignalStrength());

        markTextWithArrow("Link Downstream Bandwidth kbps: " + (networkCapabilities.getLinkDownstreamBandwidthKbps()));
        markTextWithArrow("Link Upstream Bandwidth kbps: " + (networkCapabilities.getLinkUpstreamBandwidthKbps()));
        markTextWithArrow("hasTransport cellular:" +networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR));
        markTextWithArrow("hasTransport wifi:" +networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI));

results are:

    ━━━━━━━━━━━━━━━━━━━signal strength:-30
    ━━━━━━━━━━━━━━━━━━━Link Downstream Bandwidth kbps: 4125
    ━━━━━━━━━━━━━━━━━━━Link Upstream Bandwidth kbps: 76415
    ━━━━━━━━━━━━━━━━━━━hasTransport cellular:false
    ━━━━━━━━━━━━━━━━━━━hasTransport wifi:true

My true network speed is:

239.32 Mbps - downstream

23.97 Mbps - upstream

results from phone run connected to wifi:

    ━━━━━━━━━━━━━━━━━━━signal strength:-38
    ━━━━━━━━━━━━━━━━━━━Link Downstream Bandwidth kbps: 672000
    ━━━━━━━━━━━━━━━━━━━Link Upstream Bandwidth kbps: 672000
    ━━━━━━━━━━━━━━━━━━━hasTransport cellular:false
    ━━━━━━━━━━━━━━━━━━━hasTransport wifi:true

Emulator network is set to full

What I need to do to get correct values in my app?

Krzysztof
  • 1,861
  • 4
  • 22
  • 33
  • Did you test this on a real device? Maybe this has to do with emulated networking via virtual router. Are you connecting via a proxy? (see: https://developer.android.com/studio/run/emulator-networking#proxy) Have you tried setting the network speed for emulator? (see: https://stackoverflow.com/a/6236379/11278807) – nulldroid Dec 31 '21 at 11:06
  • yes - I updated post – Krzysztof Dec 31 '21 at 11:11
  • Looks like it never shows the true bandwith speed. getLinkDown/UpstreamBandwidthKbps() always only refers to the estimated first hop transport bandwidth (only mobile data, not wifi), which is not equivalent with the bandwith you'll get when your traffic will be routed over the network to reach your endpoint. To get true bandwith, you would need to download a file from a close server and measure DL time. For Wifi, you can use WifiManager. https://stackoverflow.com/a/31696452/11278807 https://newbedev.com/android-how-to-determine-network-speed-in-android-programmatically – nulldroid Dec 31 '21 at 11:22
  • Also, this might help? https://stackoverflow.com/questions/8225791/check-the-bandwidth-rate-in-android Maybe facebook network library does the job. – nulldroid Dec 31 '21 at 11:32
  • @nulldroid put second comment as answer, I will accept it. – Krzysztof Dec 31 '21 at 21:57

0 Answers0