How to find network type is 2G/3G/4G exactly

867 views
Skip to first unread message

Bunty syed

unread,
Apr 17, 2012, 7:10:35 AM4/17/12
to Android Developers, android-...@googlegroups.com
HI,

I want to find if the connected network falls under 2G ,3G or 4G..

I went through ConnectivityManager / TelephonyManager but it gives
network type like gprs,edge,etc...

In device,we will find a tick mark like use only 2G network.

Can anybody tell me how native android decides that whether the
connected network falls under 2G..

ashiq sayyad

unread,
Apr 17, 2012, 9:26:27 AM4/17/12
to android-...@googlegroups.com, Android Developers
I think u can write some logic based on the approximate bit rates assumed for edge,gprs,umt,etc....
Regards,
Ashiq


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.


Narseo Vallina Rodriguez

unread,
Apr 17, 2012, 9:27:54 AM4/17/12
to android-...@googlegroups.com, Android Developers

paldan

unread,
Apr 17, 2012, 9:52:46 AM4/17/12
to android-platform
Hi,

native RIL requests involved for identyfing network type are:

RIL_REQUEST_REGISTRATION_STATE
RIL_REQUEST_GPRS_REGISTRATION_STATE

What these requests do depends on the native RIL driver, but you can
find the prototype of the requests in
hardware/ril/include/telephony/ril.h

regards,
Daniele

tracy.b.hu

unread,
Apr 17, 2012, 11:26:49 PM4/17/12
to android-platform, Android Developers, android-platform
Hi,
 
Please try below method, but it's hard to find to  real network type. As you may know, some network type belong to both 2g and 3g.
 
public static boolean is3G(int networkType){
        if (networkType == ConnectivityManager.TYPE_MOBILE) {
            TelephonyManager telephonyManager = (TelephonyManager) AppContent.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
            networkType = telephonyManager.getNetworkType();
        }
        return (networkType == TelephonyManager.NETWORK_TYPE_UMTS
                || networkType == TelephonyManager.NETWORK_TYPE_HSDPA
                || networkType == TelephonyManager.NETWORK_TYPE_CDMA
                || networkType == TelephonyManager.NETWORK_TYPE_EVDO_0
                || networkType == TelephonyManager.NETWORK_TYPE_EVDO_A
                || networkType == TelephonyManager.NETWORK_TYPE_UNKNOWN);
    }
 

Thanks,
Henry Hu

Bunty syed

unread,
Apr 18, 2012, 8:13:38 AM4/18/12
to android-...@googlegroups.com
Thanks man..

Bunty syed

unread,
Apr 18, 2012, 8:14:22 AM4/18/12
to android-...@googlegroups.com
Thanks for the reply..

Reply all
Reply to author
Forward
0 new messages