is 2G Network Connection - Android Network

Android examples for Network:Network Connection

Description

is 2G Network Connection

Demo Code


//package com.java2s;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static boolean is2G(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context
                .getSystemService("connectivity");
        NetworkInfo activeNetInfo = connectivityManager
                .getActiveNetworkInfo();
        if ((activeNetInfo != null)
                && ((activeNetInfo.getSubtype() == 2)
                        || (activeNetInfo.getSubtype() == 1) || (activeNetInfo
                        .getSubtype() == 4))) {
            return true;
        }/*from   www  . j  a  v  a  2s.  c  o m*/
        return false;
    }
}

Related Tutorials