问题标签 [android-wake-lock]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
android - 系统范围的唤醒锁定和释放取决于电源连接
我正在尝试开发一个简单的 android 应用程序,当设备插入时,即通过扩展坞,屏幕会获取唤醒锁,这样屏幕就不会关闭,无论它们在什么应用程序中,当拔下唤醒时锁被释放。
目前我没有运行任何服务,因为我认为它不需要。它接收电源连接和电源断开的广播意图。连接电源时,它似乎成功获取了唤醒锁,但当电源断开时,它试图释放唤醒锁,但抛出空指针异常。我猜是因为该应用程序不一定正在运行并且没有服务,因此不会保留该变量。
下面是我正在使用的接收广播的代码。
下面是获取和释放唤醒锁的代码。
有没有办法可以工作我需要有一个服务在获取唤醒锁时运行,一旦断开电源释放并停止服务。
感谢您的任何帮助,您可以提供。
android - 如果启用了完全唤醒锁,唤醒锁是否会在设备锁定时自动释放
我正在开发一个 android 项目,我正在使用 PowerManager.FULL_WAKE_LOCK 来确保屏幕始终保持开启状态。
我想知道用户是否在获取唤醒锁时锁定了设备,唤醒锁是否会自动释放,或者我是否需要自己处理。
我做了一个谷歌搜索,但什么都想不出来。
谢谢
android - PARTIAL_WAKE_LOCK 杀死了我的媒体播放器
我实现了一个唤醒锁,以避免在屏幕关闭时停止我的 MediaPlayer(仅播放本地文件)。由于我不想耗尽电池,我尝试了 PARTIAL_WAKE_LOCK。但它没有效果:屏幕关闭会杀死我的玩家。FULL_WAKE_LOCK 工作正常,但屏幕按预期保持打开状态,耗尽电池...
我究竟做错了什么?
谢谢!L.
android - 4.2 中的 Android Wakelocks 用于闪烁屏幕
在 4.2 之前的 android 版本中,我曾经有一些代码在通知进入应用程序时闪烁屏幕(如果用户希望它闪烁)。我用了:
因此,“获取”方法将打开屏幕(如果尚未打开),“释放”方法将直接将其关闭。
在 android 4.2 中,当您释放唤醒锁时似乎不会发生关闭,但只有在达到显示器的屏幕超时设置时才会发生关闭(默认似乎是 2 分钟)
释放唤醒锁时,有什么方法可以关闭它。我在 API 中看到了一些关于专门打开和关闭屏幕的内容,但我有点不确定是否使用,因为如果有人正在做某事,我不希望应用程序关闭屏幕,所以唤醒锁似乎运作良好。有什么建议么?
android - 接收推送通知时唤醒锁定。有没有简单的方法?
我遵循了 android-hive 的推送通知指南。我已经完成了自己的应用程序并实现了接收推送所需的东西。
它工作得很好,我得到了推送和一条消息,但事情是,我希望屏幕在我得到推送时亮起。即使在最初的 androidhive-code 唤醒锁对我来说也不起作用。当我收到新的推送通知时,必须有一些简单的方法来唤醒屏幕,对吗?
非常感谢您的帮助!
android - Start an Activity even when Android phone is in locked mode / on lock screen
How I can start my activity even when phone is in locked mode so I can access my application?
I want to ring an alarm first using ringAlarm()
then goes to another activity that will display alertdialog
to stop the alarm.
It works fine if phone is active, but when the phone is locked, it just alarms continuously and by the time i unlock the phone, the stop alarm button doesn't activate. Please help me. Thanks for help in advance.
Here is my code:
I've seen a code on how to do it but I didn't know how to use it. so I'm still having the same problem. Here's the code.
android - 全局获取wakelock和在handler.postDelayed()块中定义的setResult()时不调用onActivityResult()
我有一些在屏幕打开时执行的代码,但是当我关闭屏幕电源时,执行中有一些问题(即使在全局获取 Wakelock 之后)。我有一个获取唤醒锁并调用活动的服务 - ExecuteScript 使用以下代码:
执行脚本.java:
在我的 ScriptActivity(调用 Service 并执行需要 30 秒的操作)中。但是,在我的情况下没有调用 onActivityResult() 。我不确定为什么会发生这种情况。请帮我。
我在 handler.postDelayed() 块中定义了 setResult()。我有如下代码:
ScriptActivity.java
更新:使用绑定服务也不起作用。对此有什么想法吗?
android - Android - 唤醒和解锁设备
应用程序描述: 该应用程序旨在作为特定客户的安全程序(不公开部署)。当应用程序在一段时间内未检测到移动时,如果应用程序处于后台或设备处于睡眠状态,则应用程序应发出警报并将其自身带到前台。
问题: 如果设备处于睡眠状态并被锁定,我们需要唤醒并解锁设备。使用在 SO 和其他地方发现的各种技术,我们已经能够(部分)唤醒和解锁设备,但是只有在设备物理插入计算机时才能正常运行。如果设备自己拔掉插头,我们测试唤醒解锁,什么都不会发生;设备似乎保持睡眠状态,应用程序似乎什么都不做(没有警报)。
我使用过这篇关于使用 PowerManager 和 KeyguardManager的文章,以及这篇文章使用窗口标志。
以下是目前用于唤醒设备的代码:
从我看到/使用的其他一些 SO 问题的评论和帖子来看,似乎 PowerManager / KeyguardManager 代码应该可以解决问题。同样,正如我之前所说,当设备通过 USB 插入开发机器时,它在技术上确实有效,但在设备分离时绝对没有任何作用。
另请注意,这是我们的第一个 Android 应用程序,因此完全意识到我们可能完全偏离了我们正在尝试做的事情。欢迎任何建议。
所以简而言之,鉴于上面的代码,为什么设备的行为会根据它是否插入而如此不同,我们应该改变什么来唤醒和解锁设备?预先感谢您的协助!
android - 有没有办法在屏幕关闭后以编程方式找到让您的手机保持清醒的应用程序?
有没有办法在屏幕关闭后以编程方式找到让您的手机保持清醒的应用程序?
我需要检测哪些应用程序保持唤醒状态,以便为用户做一些统计?
例如,在 2 月 11 日 13:44,应用 X 保持唤醒状态 20 分钟。ETC
android - Service goes to standby when device sleeps - Android
Envrionment: Eclipse
Language: Java (Android)
I have a bit of a problem, which I didn't realise until I tested my application out on a device. I always thought that services would continuously be running in the background, even when the phone's sleeping. I found out that this is not the case, so, my question is that does the service start up again once you wake your device up? And if not, how would I cause the service to start-up again.
Would I be able to wake the phone every 5 minutes or so, just to run my service, which will last 30 seconds to 1 minute. And then make the phone sleep again?
Thanks in advance.
EDIT: I am very new to Android programming and would really appreciate if someone would tell me how to use WakefulIntentService. I have a service that is searching for the user's GPS Location every so often, and when the phone goes to sleep, I want my service to still look for their location. How would I go about using the WakefulIntentService for this? And would I be able to use it in this scenario.
Thanks.