Battery implementation Service class added.
This commit is contained in:
parent
f8901f2c8f
commit
1b9023d710
@ -0,0 +1,37 @@
|
|||||||
|
using Android.Content;
|
||||||
|
using Android.OS;
|
||||||
|
using GMCabsDriverAssistant.Services;
|
||||||
|
using GMCabsDriverAssistantSolution.Platforms.Android.Services;
|
||||||
|
using Microsoft.Maui.Controls.Compatibility;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
[assembly: Dependency(typeof(BatteryImplementationService))]
|
||||||
|
namespace GMCabsDriverAssistantSolution.Platforms.Android.Services
|
||||||
|
{
|
||||||
|
public class BatteryImplementationService : IBatteryInfo
|
||||||
|
{
|
||||||
|
public bool CheckIsIgnoringBatteryOptimizations()
|
||||||
|
{
|
||||||
|
|
||||||
|
PowerManager pm = (PowerManager)global::Android.App.Application.Context.GetSystemService(Context.PowerService);
|
||||||
|
//enter you package name of your application
|
||||||
|
bool result = pm.IsIgnoringBatteryOptimizations("au.com.gmcabs.driverassistant");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Obsolete]
|
||||||
|
public void StartSetting()
|
||||||
|
{
|
||||||
|
Intent intent = new Intent();
|
||||||
|
|
||||||
|
intent.SetAction(global::Android.Provider.Settings.ActionIgnoreBatteryOptimizationSettings);
|
||||||
|
global::Android.App.Application.Context.StartActivity(intent);
|
||||||
|
Launcher.OpenAsync(intent.ToString());
|
||||||
|
// StartActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user