1

I searched through many questions, but I can only find out how to get the wifi speed. My issue is that I want to know how to calculate the mobile data speed. How can I do this?

bucky
  • 57
  • 8
  • 2
    What have you tried yourself? (also, please refrain from tag-spam. Android fragments and your IDE don't have any specific relation to your root issue) – nanofarad Jun 18 '16 at 15:23
  • I am talking about android programming. So i add all the android studio related tags. And sorry :( – bucky Jun 18 '16 at 15:28
  • Have you tried downloading a file with a size known in advance and calculating the average download speed with that? Or do you need near-realtime speed reports? – Machinarius Jun 18 '16 at 15:38
  • i need real time @Machinarius – bucky Jun 18 '16 at 15:39
  • http://stackoverflow.com/a/3028660/528131 The AsyncTask code in that answer downloads a file "manually", you can take the time it takes to download fixed size chunks of data to somewhat accurately determine data link speed. Be mindful your own code execution time is included in this calculation, so it does not report accurate values. – Machinarius Jun 18 '16 at 15:53
  • Anyways I am reading the codes of Internet speed lite @Machinarius – bucky Jun 18 '16 at 16:04

1 Answers1

0

You can use this https://developer.android.com/reference/android/net/TrafficStats.html#getUidRxBytes(int) to get the data usage and then divide by time to get the speed. Or try this one: https://github.com/commonsguy/cw-andtuning/tree/master/TrafficMonitor

Amir
  • 1,667
  • 3
  • 23
  • 42