AlarmManager is not triggered when App is closed

后端 未结 3 700
臣服心动
臣服心动 2021-01-03 12:07

I have some in-App notification to show to users at a specific time but nothing is shown when the App is closed.

Setting alarm:

Intent alarmIntent =          


        
相关标签:
3条回答
  • 2021-01-03 12:39

    Your AndroidManifest.xml should be like this:

    <receiver android:name=".ReminderAlarmManager">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>
    
    <service android:name=".OrderReminderNotificationService "/>
    
    0 讨论(0)
  • 2021-01-03 12:52

    Your device won't allow you to trigger the alarm since it need to save some battery power. So, go to SETTINGS ->Battery/power saver->Apps then choose your app, after that select "no restriction"

    0 讨论(0)
  • 2021-01-03 12:56

    The alarm manager doesn't trigger the Intent services on certain phones. I was testing the app on a Oneplus 3T the entire day before I realized there was nothing wrong with the code. Just tested the same app on a Moto G, and it works as expected.

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