determining internet speed in android
Asked Answered
H

1

2

I am developing an android video-streaming application where I must detect internet speed to adjust my stream quality according to that speed.

I've searched in the net about how to detect internet speed in android but I found only one method of downloading file and knowing its size to determine the bandwidth :

 bandwidth = contentLength / ((endTime-startTime) *1000);

Is there any other possible way to determine internet bandwith in android without downloading any file I don't want to disturb my video streaming by additional file downloading

Thanks.

Hautevienne answered 2/5, 2013 at 8:58 Comment(6)
how are you streaming the video, ie. what protocols are you using? changing the speed can be done dynamically if for example frames are not arriving in time reduce quality (using rtp/rtmp)Homophone
my point being that you are downloading frames, so you can determine sppeds using the method you've posted adapted to the frames from your videoHomophone
frames are downloaded in my native code(its a new streaming protocol) and in my native code(c++) i can't access to informations about my device so i must use java to detect my bandwidthHautevienne
a new streaming protocol? already installed on android devices?Homophone
its a long story it is a new streaming protocopl that i've intergrated in the aosp and tested it through my new media player successfullyHautevienne
and it provides no sort of feedback ass to what frames are in the buffer or what frames didn't arrive on time .. .these things will be essential to know what's going on at a network level. when streaming you must be able to adapt to changes in network on the fly these sort of metrics will be essential to get from some sort of api connected to the native codeHomophone
S
1

If you are on 2G,3G,4G, I don't think there is a standard way of finding out, maybe you can assume automatically that 2G,3G or 4G is slow.

If you are using wifi then you can calculate internet speed using WifiManager class

WifiInfo wifiInformation = wifiManger.getConnectionInfo();

and then from the WifiInfo you can get the current speed :

int speedInMbpsSpeed = wifiInformation.getLinkSpeed();

Segmental answered 28/4, 2016 at 14:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.