コード例 #1
0
ファイル: PowerManager.Android.cs プロジェクト: jokm1/uno-2
        private static void RegisterAndroidBatteryChangedBroadcastReceiver()
        {
            if (_batteryChangedBroadcastReceiver == null)
            {
                _batteryChangedBroadcastReceiver = new BatteryChangedBroadcastReceiver();
            }
            var filter = new IntentFilter();

            filter.AddAction(Intent.ActionBatteryChanged);
            Android.App.Application.Context.RegisterReceiver(_batteryChangedBroadcastReceiver, filter);
        }
コード例 #2
0
ファイル: PowerManager.Android.cs プロジェクト: jokm1/uno-2
        private static void UnregisterAndroidBatteryChangedBroadcastReceiver()
        {
            //two events use this broadcast
            if (_batteryStatusChanged != null ||
                _remainingChargePercentChanged != null)
            {
                return;
            }

            if (_batteryChangedBroadcastReceiver != null)
            {
                Android.App.Application.Context.UnregisterReceiver(_batteryChangedBroadcastReceiver);
                _batteryChangedBroadcastReceiver = null;
            }
        }