Nikhil Pawar
Nikhil Pawar

Reputation: 301

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

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.

Upvotes: 0

Views: 464

Answers (1)

Rafael T
Rafael T

Reputation: 15689

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_***
}

Upvotes: 1

Related Questions