Android P Beta - AlarmManager Notifications not working

后端 未结 2 1457
自闭症患者
自闭症患者 2021-02-15 17:20

I\'m testing my application on Android P beta release 4. My app\'s targetSdkVersion is 27

It has been observed that alarm manager notifications are not

相关标签:
2条回答
  • 2021-02-15 17:46

    As you yourself mentioned the new App Standby Buckets feature of Power Management is likely to be the cause. The new documentation states:

    If an app is in the frequent bucket [or below], the system imposes stronger restrictions on its ability to run jobs and trigger alarms

    and

    In particular, the bucket determines how frequently the app's jobs run, how often the app can trigger alarms

    Additionally, if you view Power Details you can get a rough idea of the delay times.

    Worth noting is that it appears your bucket is based on average usage (and machine learning) not on current usage - which means even if your app has just been in the foreground, the buckets play some role

    0 讨论(0)
  • 2021-02-15 17:49

    This is happening because of Power management feature introduced in Android Pie.

    In android P, strict restrictions are introduced on the apps running in background. These restrictions are explained here

    As we can see in the above link, if we connect the device to charging there are no restrictions imposed on the device and notifications are working properly. However, if we remove the device then Android system adds the certain restrictions for the apps running in background.

    We can turn off this restrictions by turning off battery optimization for our application from device settings. Search for battery optimization in settings and turn it off for our application.

    Also, testing the notifications by changing the device date and time was a hack that worked fine till now but in Android P, we've to either test them in real time scenario or turn off battery optimization for our application to test them.

    I hope this will clear our doubts.

    0 讨论(0)
提交回复
热议问题