Search code examples
androidnetwork-programmingandroid-wifi3g

How to calculate connection speed


I'm developping a radio app and I need to know if the user's connection speed is fast enough, if it's slow I'll show a message saying that the streaming may be slow sometimes.

The problem I'm having is in calculate the speed connection from the user.

I've read some opinions about that and I only found answers based on internet type (2g, 3g, wi-fi). I found this answer : Detect network connection type on Android that is almost what I needed, but the method "isConnectionFast" isn't accurate because it doesn't make a real test connection, it's just based on some properties.

I think that the best way is to download an image with a determinated size and calculate the time that took to finish the download. But I'm not knowing how to do that in android.

Can anyone help me ? Thank you


Solution

  • Well it seems that you already know the basic steps for doing a speedtest but I would like to explain why is that probably a waste of time in this case.

    If we're talking about cellular connections there are standards that specify the speed and the answer you linked is an example of how to get an estimate based on that. Sure, you will never get the full speed and the speed test would provide a better estimate but just for that moment in time. There are many factors which may influence client's speed and most of them are changing every second so the test you made at the beginning is pretty much useless if the client is mobile. For wifi estimating the speed is a bit harder without a speedtest because the bandwidth is usually not limited by the technology but the plan user is paying for. Anyway those speeds are almost certainly enough for a radio stream.

    You didn't provide much info about the streams itself but from my experience (as a user) for 128kbps streams everything above EDGE is sufficient, providing your buffering is enough to compensate for short speed degradation or connection losses caused by handoffs etc.