How to get programmatically the Cell Signal Strength for Samsung Galaxy Android Devices? What is correct way to get Cell Signal Strength in android devices?

1,430 views
Skip to first unread message

Muhammad Rashid Mahmood

unread,
Oct 11, 2017, 12:57:11 PM10/11/17
to android-platform
Hi All,

I am facing an issue with Samsung Galaxy Android Device (currently S5) to get Cell Signal Strength. I am using following APIs that gives correct info for Nexus 5 but wrong on Samsung Galaxy S5.

    public static int getCellSignalStrength(Context context){
int strength= 0;
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.
TELEPHONY_SERVICE);
List<CellInfo> cellInfos = telephonyManager.getAllCellInfo();
//This will give info of all sims present inside your mobile
if(cellInfos!=null && cellInfos.size() > 0){
for (int i = 0 ; i<cellInfos.size(); i++){
    if(cellInfos.get(i) instanceof CellInfoWcdma){
CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) telephonyManager.getAllCellInfo().get(0);
CellSignalStrengthWcdma cellSignalStrengthWcdma = cellInfoWcdma.getCellSignalStrength();
strength = cellSignalStrengthWcdma.getDbm();
break;
}else if(cellInfos.get(i) instanceof CellInfoGsm){
CellInfoGsm cellInfogsm = (CellInfoGsm) telephonyManager.getAllCellInfo().get(0);
CellSignalStrengthGsm cellSignalStrengthGsm = cellInfogsm.getCellSignalStrength();
strength = cellSignalStrengthGsm.getDbm();
break;
}else if(cellInfos.get(i) instanceof CellInfoLte){
CellInfoLte cellInfoLte = (CellInfoLte) telephonyManager.getAllCellInfo().get(0);
CellSignalStrengthLte cellSignalStrengthLte = cellInfoLte.getCellSignalStrength();
strength = cellSignalStrengthLte.getDbm();
break;
}
}
return strength;
}

thanks
Reply all
Reply to author
Forward
0 new messages