<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
{
PowerManager pm = (PowerManager)GetSystemService(PowerService);
if (!pm.IsIgnoringBatteryOptimizations(PackageName))
{
Intent intent = new(Settings.ActionRequestIgnoreBatteryOptimizations);
intent.SetData(Android.Net.Uri.Parse($"package:{PackageName}"));
StartActivity(intent);
}
}
https://developer.android.google.cn/training/monitoring-device-state/doze-standby?hl=zh-cn#support_for_other_use_cases