Das ist mein Konspekt von dem Online-Kurs Android Development: Building Battery-Conscious Apps
…
Wake-Up has costs:
Official documentation: http://developer.android.com/topic/performance/power/#lazy
Smart Design (aka Lazy First design)
setExact can drift)Takeaways:
Two posibilities to trigger a broadcast receiver:
Example of triggering explicitly:
Intent i = new Intent("my.action.name") .setComponent(new ComponentName(context.getPackageName(), className)); context.setBroadcast(i);
This post scriptum is not based on the online course, but on other articles.
From Android Battery Optimization for Avoiding Doze Mode and App Standby
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Intent intent = new Intent(); String packageName = getPackageName(); PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); if (!pm.isIgnoringBatteryOptimizations(packageName)) { intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + packageName)); startActivity(intent); } }