How get from android CellSignalStrengthLte.Rsrp

DustOfRust 141 Reputation points
2021-04-11T15:52:44.653+00:00

How to get CellSignalStrengthLte.Rsrp value from android?
Please give me some examples

I tried with TelephonyManager but I only have SignalStrength available, I don't see SignalStrengthLTE available.

https://learn.microsoft.com/en-us/dotnet/api/android.telephony.cellsignalstrengthlte.rsrp?view=xamarin-android-sdk-9#Android_Telephony_CellSignalStrengthLte_Rsrp

        TelephonyManager mTel;  
                mTel = (TelephonyManager)GetSystemService(TelephonyService);  

                return mTel.GetImei(0).ToString()+" " + mTel.SignalStrength.Level.ToString();  
  
Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,971 Reputation points
    2021-04-12T07:23:43.277+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Hi, DustOfRust. To get the 'CellSignalStrengthLte.Rsrp' propety, try using the following code.

       TelephonyManager tm = (TelephonyManager)this.GetSystemService(Context.TelephonyService);  
       var cellInfoList = tm.AllCellInfo;  
         
       foreach (var item in cellInfoList)  
       {  
           if (item.GetType() == typeof(CellInfoLte))  
           {  
               var value = ((CellInfoLte)item).CellSignalStrength.Rsrp;  
           }  
       }  
    

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. andrea rodriguez 1 Reputation point
    2021-07-21T18:40:26.457+00:00

    Hi JarvanZhang-MSFT, I have been trying to get various parameters from the LTE network but I see that the AllcellInfo property returns a collection with zero elements. I only get general values such as IMEI, ASU, network etc.
    I comment that I add the location permissions and that the minimum Android version and destination in the Manifest are API 22 (Android 5.1)

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCEPT_HANDOVER" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION
    

    CODE (IDE VS / Xamarin.Essentials):

        private void _CellInfoButton_Click(object sender, EventArgs e)
        {
            _cellSignalStrengthListener2 = new CellSignalStrengthListener(this);
            TelephonyManager _telephonyManager2 = (TelephonyManager)this.GetSystemService(Context.TelephonyService);
            //_telephonyManager2.Listen(_cellSignalStrengthListener2, PhoneStateListenerFlags.CellInfo);  
    
            var list = _telephonyManager2.AllCellInfo;   // list with 0 elements!!
            Ckpi cellDataEntity = new Ckpi();
    
            if (list != null)
            {                
                _CoberturaTextView.Text = string.Format("Cubrimiento:    {0}", list.Count);     // 0 elements!!
                foreach (var item in list)
                {
                    if (item.GetType() == typeof(CellInfoLte))
                    {
                        cellDataEntity.Cobertura = ((CellInfoLte)item).CellSignalStrength.Rsrp;
                        cellDataEntity.Calidad = ((CellInfoLte)item).CellSignalStrength.Rsrq;
                        cellDataEntity.Señal_ruido = ((CellInfoLte)item).CellSignalStrength.Rssnr;
                        cellDataEntity.Calidad_celda = ((CellInfoLte)item).CellSignalStrength.Cqi;
                        cellDataEntity.Ancho_banda = ((CellInfoLte)item).CellIdentity.Bandwidth;
                        cellDataEntity.Cid = ((CellInfoLte)item).CellIdentity.Ci;
                        cellDataEntity.Canal = ((CellInfoLte)item).CellIdentity.Earfcn;
                        cellDataEntity.Mcc = ((CellInfoLte)item).CellIdentity.MccString;
                        cellDataEntity.Mnc = ((CellInfoLte)item).CellIdentity.MncString;
                        cellDataEntity.Pci = ((CellInfoLte)item).CellIdentity.Pci;
                        cellDataEntity.Tac = ((CellInfoLte)item).CellIdentity.Tac;
    
                        _CoberturaTextView.Text = string.Format("Cubrimiento:    {0}", cellDataEntity.Cobertura); // nothing!! 
                    }
                }
            }
        }
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.