At first I thought that you wanted you to be interested in the maximum speed of loading / unloading, for example, the information that Speedtest.net provides. Now I believe that you meant that you are interested in receiving current network traffic. I left an explanation regarding my initial assumption below.
New answer (if you are interested in receiving current upload / download traffic):
Take a look at the TrafficStats class. It has functions such as getMobileRxBytes() and getMobileTxBytes() , which give the number of bytes received and transmitted since loading, respectively. You can get these values ββevery second, then do calculations to find the difference per second (or "bytes per second").
// set this to true when you want it to stop boolean mStopHandler = false; Runnable runnable = new Runnable() { @Override public void run() { // complete calculations if (!mStopHandler) { mHandler.postDelayed(this, 1000); //runs every second } } }; // begin task mHandler.post(runnable);
Original answer (assuming you are interested in maximum upload / download speed):
This is not possible according to how you intend. Internet speed is the data transfer rate between your device and the destination server you have specified. When you go to Speedtest.net, you send information to your servers and receive from their servers as quickly as possible, and it tells you the speed that it detects. To be able to see speed statistics in real time, you need to constantly communicate with a remote server. (In addition, this server should be able to both load and load faster than the client, otherwise you will finish testing the maximum transmission speed of the Internet connection to the server, not the client!).
RogueBaneling
source share