示例#1
0
        static void StartPowerListeners()
        {
            if (!Platform.HasApiLevel(BuildVersionCodes.Lollipop))
            {
                return;
            }

            powerReceiver = new PowerBroadcastReceiver(OnPowerChanged);
            Platform.AppContext.RegisterReceiver(powerReceiver, new IntentFilter(PowerManager.ActionPowerSaveModeChanged));
        }
示例#2
0
        static void StopPowerListeners()
        {
            if (!Platform.HasApiLevel(BuildVersionCodes.Lollipop))
            {
                return;
            }

            try
            {
                Platform.AppContext.UnregisterReceiver(powerReceiver);
            }
            catch (Java.Lang.IllegalArgumentException)
            {
                Debug.WriteLine("Power receiver already unregistered. Disposing of it.");
            }
            powerReceiver.Dispose();
            powerReceiver = null;
        }