0

What i want to achive is restrict user not to reach server when user do not have a stable internet or consider user as offline.

I tried to like get a connection type but did not success. Its crashing when we are trying to get typeNetworkInfo

  • Android Code:
public static bool IsConnectedFast(Context context)
{
     ConnectivityManager cm = (ConnectivityManager)context.GetSystemService(Context.ConnectivityService); 
     NetworkInfo info = cm.ActiveNetworkInfo;

     TelephonyManager tm = TelephonyManager.FromContext(context);
     return (info != null && info.IsConnected && NetworkConnectivity.IsConnectionFast(info.Type, tm.NetworkType)); // Getting crash here when trying with mobile connection
}

1 Answers1

0

I found some useful info on the Internet. Have you tried them?

For Xamarin.Andriod, you could use native API:

How to get WIFI signal strength

How to get current WiFi signal strength in Xamarin.Forms running on Android?

For Xamarin.iOS, many answers suggested that there is no API for iOS:

Wifi/Cellular Signal strength in Xamarin Forms

Xamarin form: How to check the signal strength on both android and iOS

Is it possible to get Wifi & Cellular signal strength on iOS?

Liqun Shen-MSFT
  • 3,490
  • 2
  • 3
  • 11