I implemented an BroadcastReceiver
for Android-Platform to detect whenether the Devices Battery is being Charged or not. Unfortunately, it doesn't seem to work on my Device which has Android 10 installed (Android 10 is my minimum requirement for the App).
I need this BroadcastReceiver
to be triggered even if the App is not running. Therefore an Implicit broadcast would be an excellent choice instead of register an BroadcastReceiver
while the App is running.
Permissions set within "AndoirdManifest.xml
"
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
My PowerConnectedBroadcastReceiver looks like this:
[BroadcastReceiver(Enabled = true, Exported = true)]
[IntentFilter(new[] { Intent.ActionPowerConnected, Intent.ActionPowerDisconnected, Intent.ActionDockEvent, Intent.ActionBatteryChanged }, Priority = (int)IntentFilterPriority.HighPriority)]
public class PowerConnectedBroadcastReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
Console.WriteLine($"PowerConnectedBroadcastReceiver received an intent: {intent}");
}
}
What am I doing wrong?
Any Kind of advise would be appreciated.