[英]Android: During alarm - if user locks screen or goes to home screen - how to bring it back again?
so I am facing small bit of so to call - exploit/bug. 因此,我面临这样的挑战-漏洞利用/错误。 I have an app which triggers activity and wakes up phone from lockscreen and shows alarm, all works fine sound works but there are few scenarios in which I have problem: If user clicks home button it just minimizes app and thats it, it remains running in background.
我有一个可触发活动并从锁屏唤醒电话并显示警报的应用程序,所有声音工作正常,但在少数情况下我有问题:如果用户单击“主页”按钮,它将应用程序最小化,仅此而已,它仍在运行背景。 If user locks screen, the alarm is silenced - if unlocked within 10 seconds it continues, if unlocked after 10 seconds it's minimized and runs in background.
如果用户锁定屏幕,则警报将静音-如果在10秒钟内将其解锁,警报将继续,如果在10秒钟后被解锁,则警报将最小化并在后台运行。
How would I go about fixing these? 我将如何解决这些问题? what approach would you suggest?
您会建议哪种方法? I assume alarm activity goes into onPause?
我认为警报活动进入了onPause吗? if so I was thinking of making new Handler and wake up phone in 10 seconds in onPause method but wondering if there is any better approach?
如果是这样,我正在考虑使用onPause方法制作新的Handler并在10秒内唤醒电话,但想知道是否还有更好的方法?
I dont think post a Handler
is a good idea, there is no grantee that your Activity
dos not get destroyed
by Android system, and then you Handler
will not work. 我认为
post a Handler
不是一个好主意,没有被授予人认为您的Activity
不会被Android系统destroyed
,然后您的Handler
将无法工作。
I suggest to set a new Alarm
(after 10 seconds) that run a Service/Broadcast
in onPause()
, you can send the time of setting the Alarm
in the PindingIntent
. 我建议在
onPause()
设置一个运行Service/Broadcast
的新Alarm
(10秒后onPause()
,您可以在PindingIntent
发送设置Alarm
的PindingIntent
。 get that time check it or cancel the Alarm
. 得到那个时间检查它或取消
Alarm
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.