Lollipop中关闭屏幕固定时如何通知

Lollipop中关闭屏幕固定时如何通知

本文介绍了在Android 5.0 Lollipop中关闭屏幕固定时如何通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在后台运行的应用程序,当手机上发生特定事件时,它会启动活动.我发现在Android 5.0中,当用户使用另一个应用程序打开了屏幕固定功能时,startActivity(intent)调用将被完全忽略.我的应用程序不知道该活动没有开始,因此,在用户手动重新打开我的应用程序之前,用户将没有其他机会看到该活动.

I have an app that runs in the background and starts an activity when a certain event occurs on the phone. I'm finding with Android 5.0 that when the user has screen pinning turned on with another app, the startActivity(intent) call is ignored completely. My app doesn't know that the activity didn't start, so the user then won't have another chance to see the activity until they manually reopen my app.

关闭屏幕固定功能后,是否可以注册某种事件通知我,以便我可以重新尝试开始我的活动?

Is there any sort of event I can register for to be notified when screen pinning is turned off, so I can reattempt to start my activity?

推荐答案

这是ActivityManager类中的方法,该方法在屏幕固定的情况下告知当前任务的状态(是否锁定):

Here is method in ActivityManager class which tells status of current task if locked or not in case of screen pinning:

!mActivityManager.isInLockTaskMode()

有关更多详细信息,请检查此链接: http://developer.android.com/reference/android/app/ActivityManager.html#isInLockTaskMode%28%29

For more details check this link:http://developer.android.com/reference/android/app/ActivityManager.html#isInLockTaskMode%28%29

这篇关于在Android 5.0 Lollipop中关闭屏幕固定时如何通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 01:36