コード例 #1
0
        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;
        }
コード例 #2
0
        static void StartListeners()
        {
            Permissions.EnsureDeclared(PermissionType.NetworkState);

            conectivityReceiver = new ConnectivityBroadcastReceiver(OnConnectivityChanged);
            Platform.CurrentContext.RegisterReceiver(conectivityReceiver, new IntentFilter(ConnectivityManager.ConnectivityAction));
        }
コード例 #3
0
        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
        }
コード例 #4
0
        static void StopListeners()
        {
            if (conectivityReceiver == null)
            {
                return;
            }

            Platform.CurrentContext.UnregisterReceiver(conectivityReceiver);
            conectivityReceiver.Dispose();
            conectivityReceiver = null;
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 static void StopListeners()
 {
     Platform.CurrentContext.UnregisterReceiver(conectivityReceiver);
     conectivityReceiver?.Dispose();
     conectivityReceiver = null;
 }
コード例 #7
0
 static void StartListeners()
 {
     ValidatePermission();
     conectivityReceiver = new ConnectivityBroadcastReceiver(OnConnectivityChanged);
     Platform.CurrentContext.RegisterReceiver(conectivityReceiver, new IntentFilter(ConnectivityManager.ConnectivityAction));
 }