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
}