Android-应用更新后警报丢失 [英] Android - Alarm lost after app update

查看:72
本文介绍了Android-应用更新后警报丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Android上运行的应用,该应用会创建一个每24小时触发一次的警报。此警报正在按预期方式工作。

I have an app running on Android that creates an alarm that is fired every 24 hours. This alarm is working as expected.

但是,当我通过Google Play更新我的应用程序时,此警报丢失了,因为最终用户在应用程序启动后没有立即打开应用程序

However, when I update my app through Google Play this alarm is lost because the end user does not open the app right after the app was updated.

我的观点是,Android正在删除我的应用在更新应用时创建的警报。

My opinion is that Android is deleting the alarms my app created when the app was updated.

有人已经遇到这种情况了吗?

Does anyone already got this situation? Is there any way to persist the alarms when the app is updated?

推荐答案

您的解决方案很简单,如下所示:

Your solution is as simple as below:

在您的应用中注册了带有2个意图过滤器的广播接收器,即:

Have a broadcast receiver registered within your app with 2 intent filters namely:


  1. android .intent.action.BOOT_COMPLETED-设备重启时调用。当设备关闭时,警报会取消。

  2. android.intent.action.MY_PACKAGE_REPLACED-从Play商店或任何来源重新安装或更新您的应用后,便会调用。

您还将需要权限 android.permission.RECEIVE_BOOT_COMPLETED。在此接收器中,您可以再次启动警报。

You will also need the permission, "android.permission.RECEIVE_BOOT_COMPLETED". In this receiver you can start your alarms again.

这篇关于Android-应用更新后警报丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆