static void StopListeners() { if (conectivityReceiver == null) { return; } try { UnregisterNetworkCallback(); } catch { Debug.WriteLine("Connectivity receiver already unregistered. Disposing of it."); } try { Platform.AppContext.UnregisterReceiver(conectivityReceiver); } catch (Java.Lang.IllegalArgumentException) { Debug.WriteLine("Connectivity receiver already unregistered. Disposing of it."); } conectivityReceiver.Dispose(); conectivityReceiver = null; }
static void StartListeners() { Permissions.EnsureDeclared(PermissionType.NetworkState); conectivityReceiver = new ConnectivityBroadcastReceiver(OnConnectivityChanged); Platform.CurrentContext.RegisterReceiver(conectivityReceiver, new IntentFilter(ConnectivityManager.ConnectivityAction)); }
static void StartListeners() { Permissions.EnsureDeclared(PermissionType.NetworkState); conectivityReceiver = new ConnectivityBroadcastReceiver(OnConnectivityChanged); #pragma warning disable CS0618 // Type or member is obsolete Platform.AppContext.RegisterReceiver(conectivityReceiver, new IntentFilter(ConnectivityManager.ConnectivityAction)); #pragma warning restore CS0618 // Type or member is obsolete }
static void StopListeners() { if (conectivityReceiver == null) { return; } Platform.CurrentContext.UnregisterReceiver(conectivityReceiver); conectivityReceiver.Dispose(); conectivityReceiver = null; }
static void StartListeners() { Permissions.EnsureDeclared <Permissions.NetworkState>(); var filter = new IntentFilter(); if (Platform.HasApiLevelN) { RegisterNetworkCallback(); filter.AddAction(Platform.EssentialsConnectivityChanged); } else { #pragma warning disable CS0618 // Type or member is obsolete filter.AddAction(ConnectivityManager.ConnectivityAction); #pragma warning restore CS0618 // Type or member is obsolete } conectivityReceiver = new ConnectivityBroadcastReceiver(OnConnectivityChanged); Platform.AppContext.RegisterReceiver(conectivityReceiver, filter); }
static void StopListeners() { Platform.CurrentContext.UnregisterReceiver(conectivityReceiver); conectivityReceiver?.Dispose(); conectivityReceiver = null; }
static void StartListeners() { ValidatePermission(); conectivityReceiver = new ConnectivityBroadcastReceiver(OnConnectivityChanged); Platform.CurrentContext.RegisterReceiver(conectivityReceiver, new IntentFilter(ConnectivityManager.ConnectivityAction)); }