Да
На андроиде / app / src / main / AndroidManifest.xml добавить:
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
На андроиде / app / src / main / java // MainApplication add:
import android.os.PowerManager;
import android.net.Uri;
import android.provider.Settings;
затем на функцию public void onCreate () перед SoLoader.init ();добавить:
Intent myIntent = new Intent();
String packageName = getApplicationContext().getPackageName();
PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
if (pm.isIgnoringBatteryOptimizations(packageName))
myIntent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
else {
myIntent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
myIntent.setData(Uri.parse("package:" + packageName));
}
getApplicationContext().startActivity(myIntent);