How to get `radiotype` in Android needed for The Google Maps Geolocation API to find a location using cell tower?

441 views Asked by At

I am trying to find user location using The Google Maps Geolocation API. While using this API I need to pass radiotype in JSON request body to get the more accurate location from the cell tower. Supported values for radiotype are lte, gsm, cdma, and wcdma.

Kindly help me in finding radiotype in android.

1

There are 1 answers

3
Rafael T On BEST ANSWER

Try one of the following:

NetworkInfo info = Connectivity.getNetworkInfo(context);
int type = info.getType(); // wifi or radio
int subType = info.getSubType(); // which is what u want
String radioType = null;

you can switch over them like so to look for types you are interested in

switch(subType){
    case TelephonyManager.NETWORK_TYPE_CDMA:
        radioType = "cdma"
        break;
    case TelephonyManager.NETWORK_TYPE_GSM:
        radioType = "gsm"
        break;
    //more checks you are interested in ie
    //case TelephonyManager.NETWORK_TYPE_***
}