Check for slow internet Connection with ConnectivityManager


#1

I know with the current ConnectivityManager, I am able to tell which connection type and no connection. But what bout the scenario where you are connected to internet but connection is slow or you are not able to browse.Is there any way to check for slow internet connection or no data but connected in nativescript? @jen.looper @Pete.K @bradwaynemartin @triniwiz @NathanaelA


#2

@jen.looper @Pete.K @NathanaelA @bradwaynemartin @triniwiz anyone out there or articles you recommend to help me out with this, as this currently standing in the way of the app release which is supposed to happen later tonight


#4

If the device is on Wifi and an Android device you can find the wifi speed with https://developer.android.com/reference/android/net/wifi/WifiInfo.html

If the device is on a cell network I think it’s a bit more involved to figure out the speed. However you should be able to find out the connection type on cell (3G, LTE, etc.) I’ve never done any of this myself but definitely possible :smile:

UPDATE

Looks like the Android https://developer.android.com/reference/android/telephony/TelephonyManager.html can help determine what cell type the device is on and you can determine if it’s fast enough for your needs.


#5

If I knew enough iOS I’d get a PR into the core connectivity :confused: just not so great with iOS :smile:


#6

@bradwaynemartin :relaxed: Do think you can help with sample codes here I can start off from:sweat_smile: thnks


#7

I need only android for now


#8

I’m going from scratch here so double check the code :slight_smile:

import * as app from "application";

const appContext = app.android.currentContext;

const wifiMgr= appContext.getSystemService("wifi");
const wifiInfo = wifiMgr.getConnectionInfo();
if (wifiInfo) {
    const linkSpeed = wifiInfo.getLinkSpeed();
}

So use the connectivity module and if you determine the device is on WIFI - you can use that code to figure out the link speed (https://developer.android.com/reference/android/net/wifi/WifiInfo.html#getLinkSpeed())


#9

ok, let me try and get back to you. Thanks


#11

the question is about Android app development…