question

chbernard avatar image
0 Votes"
chbernard asked RobCaplan edited

xamarin android -> how to get the strength signal gsm ?

Hello,
i would like to know how to get the signal network strenght ?

Imagine this scenario, worker are in front of the door of one client and if signal is not good we need to not allow some operations.

thanks

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LeonLu-MSFT avatar image
0 Votes"
LeonLu-MSFT answered LeonLu-MSFT edited

Hello,​

Welcome to our Microsoft Q&A platform!

You can use TelephonyManager to monitor GSM signal strength like following code.

TelephonyManager telephonyManager = (TelephonyManager)this.GetSystemService(Context.TelephonyService);

telephonyManager.Listen(new MyPhoneStateListener(textView1), PhoneStateListenerFlags.SignalStrengths)  ;


 internal class MyPhoneStateListener : PhoneStateListener
 {
     private TextView textView1;

     public MyPhoneStateListener(TextView textView1)
     {
         this.textView1 = textView1;
     }

   

     public override void OnSignalStrengthsChanged(SignalStrength signalStrength)
     {
         base.OnSignalStrengthsChanged(signalStrength);
            
         int asu = signalStrength.GsmSignalStrength;
            
             textView1.Text = asu + "";
         
     }
 }

```

And do not forget to add following permission and grant it at runtime.


 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

I make a test in emulator. Signal None is 0, Poor is 5, Moderate is 12, good is 20, Greate is 30

95576-image.png

Best Regards,

Leon Lu



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.



image.png (83.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

chbernard avatar image
0 Votes"
chbernard answered

Hello,
thanks for time ..

i will try

thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.