static void StopBatteryListeners() { Platform.CurrentContext.UnregisterReceiver(batteryReceiver); batteryReceiver?.Dispose(); batteryReceiver = null; }
static void StartBatteryListeners() { ValidateBatteryStatsPermission(); batteryReceiver = new BatteryBroadcastReceiver(OnBatteryChanged); Platform.CurrentContext.RegisterReceiver(batteryReceiver, new IntentFilter(Intent.ActionBatteryChanged)); }