Android Check Internet Connectivity suggest change

How to check network strength in android

ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo Info = cm.getActiveNetworkInfo();
if (Info == null || !Info.isConnectedOrConnecting()) {
    Log.i(TAG, "No connection");
} else {
    int netType = Info.getType();
    int netSubtype = Info.getSubtype();

    if (netType == ConnectivityManager.TYPE_WIFI) {
        Log.i(TAG, "Wifi connection");
        WifiManager wifiManager = (WifiManager) getApplication().getSystemService(Context.WIFI_SERVICE);
        List<ScanResult> scanResult = wifiManager.getScanResults();
        for (int i = 0; i < scanResult.size(); i++) {
            Log.d("scanResult", "Speed of wifi"+scanResult.get(i).level);//The db level of signal 
        }
        
        
        // Need to get wifi strength
    } else if (netType == ConnectivityManager.TYPE_MOBILE) {
        Log.i(TAG, "GPRS/3G connection");
        // Need to get differentiate between 3G/GPRS
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Table Of Contents
39 ACRA
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close