问题标签 [wakelock]
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 - 实现 WakefulIntentService
我正在尝试使用 CommonsWare 示例实现 WakefulIntentService 。我需要将 Location 传递给 WakefulIntentService 的子类,但我无法做到这一点。
我使用以下方法调用 sendWakefulWork:
在 WakefulIntentService 类上,我有以下方法:
最后,ProtocolController 类:
android - 使用 WakeLock 保持流播放
我有一个在服务中运行的 MediaPlayer,它正在播放来自 URL(流)的音频。到目前为止,它似乎运行良好,甚至在我将手机置于待机状态时还能继续播放。
我目前没有获得唤醒锁。我的问题是:
- 在我的情况下真的有必要获得唤醒锁吗?
- 如果有必要,我应该获取什么类型的唤醒锁?
是的,这是唤醒锁的合法用例,因为我的用户明确希望音频继续播放。
android - 当应用提示用户时唤醒设备
我正在使用处理程序每隔 5 分钟重复提示用户输入一次。当设备进入睡眠模式并且屏幕被锁定时,当我的应用提示用户输入时如何唤醒设备?我已经尝试过了,但它似乎不起作用。我WAKE_LOCK
在清单中添加了权限。
有任何想法吗?
编辑:AlarmManager
用于广播自定义意图。
android - NotificationManager.notify() 失败并出现 SecurityException
Android 2.2何时NotificationManager.notify()
需要WAKE_LOCK
权限?
我从一位用户那里收到了以下堆栈跟踪:
更新Scala中的调用代码:
android - 在 Android 上关闭屏幕
我正在尝试在某些操作发生后打开和关闭显示器(让我们暂时担心关闭屏幕)。根据我对唤醒锁的理解,这就是我所拥有的:
当我在 stackoverflow 和其他地方阅读其他帖子时,他们似乎告诉我 PARTIAL_WAKE_LOCK 会关闭屏幕。但是,如果我阅读 SDK,它会说它只允许关闭屏幕。我认为这是不对的。
android - Check for wifi networks signal in sleep mode
My objective is to be able to scan changes in Wi-Fi networks (mainly to check what networks are available). Right know I'm doing it by registering a reciever:
where WifiReceiver
is my BroadcastReceiver
.
The problem is that it works only when the phone is on. As soon as it goes to sleep mode (either by pushing the power button or after some time), the receiver stops receiving. I already acquired a wake lock in onCreate of my main class and releasing it in onDestroy (it's a partial wake lock). Additionally I've tried this:
to keep wifi from sleeping. Unfortunately that didn't help.
Is there any possibility to scan for network changes, even when phone is asleep? I want to be able to check what networks are in range (by SSID). Maybe I should use another action?
Appreciate your help.
android - Service and Wake Lock Policy
As stated by the AlarmManager docs:
http://developer.android.com/reference/android/app/AlarmManager.html#RTC_WAKEUP
This means that the phone will in some cases sleep as soon as your onReceive() method completes. If your alarm receiver called Context.startService(), it is possible that the phone will sleep before the requested service is launched. To prevent this, your BroadcastReceiver and Service will need to implement a separate wake lock policy to ensure that the phone continues running until the service becomes available.
From what I've seen and read here: http://www.androidguys.com/2009/04/02/wake-up-with-the-alarm/ https://github.com/commonsguy/cw-advandroid/blob/master/SystemServices/Alarm/src/com/commonsware/android/syssvc/alarm/WakefulIntentService.java
That guys holds onto the wake lock through the service not just until it becomes available. So my question is, will a service allow the CPU to sleep if it does not have a wake policy running through the service?
android - Android:唤醒锁:是否在应用程序暂停时释放锁?
我必须使用唤醒锁(是的,出于显而易见的原因,我不应该这样做,但我得到了报酬,所以我别无选择,哈哈)
我的问题很简单:当我离开应用程序 onPause 或 onStop 时,应用程序的唤醒锁是否会自动释放?
我想避免用户关闭他的应用程序并且由于某些奇怪的原因唤醒锁仍然打开。
我当前的系统存在问题,其中应用程序通过消息处理程序调用释放唤醒锁(因为它来自另一个线程)并且这种情况发生“为时已晚”并且应用程序崩溃,因为它不再具有参考唤醒锁。
我可能不是很清楚,但这里的主要问题是:
我是否必须担心我的应用程序的唤醒锁定会在应用程序的生命周期之外影响手机。
干杯
杰森
android - Android睡眠模式下的互联网连接问题?
我有一个服务活动和一个线程。问题是当手机进入睡眠模式时,线程不发送 http 请求并且我检查网络状态,如果它没有连接,我会努力连接它,但我得到“权限被拒绝:写入安全设置需要 android.permission.WRITE_SECURE_SETTINGS”错误。但我已经将权限标签放在 AndroidManifest.xml 中。我也试试这个:
但这并不能解决我的问题。手机已经进入睡眠模式。这是我的 checkNetwork 代码:
公共类 MainActivity 扩展 Service { .....
请帮忙..
android - 在 BroadcastReceiver 中获取 WakeLock 并在 Service 中释放它的正确模式
即使经过大量研究,我仍然不能完全确定我如何实现由WakeLock
aService
开始的 a 的BroadcastReceiver
方式是否正确 - 即使它似乎工作正常。广播接收器从警报中获取发送给它的意图,因此首先从以下 API 文档开始AlarmManager
:
如果您的警报接收器调用了 Context.startService(),则手机可能会在请求的服务启动之前休眠。为防止这种情况,您的 BroadcastReceiver 和 Service 将需要实施单独的唤醒锁定策略,以确保手机继续运行直到服务可用。
所以,在onReceive()
我做:
在我做的服务中:
该SomeService.wakeLock
字段是包私有的、静态的和易失的。
我不确定使用的是检查isHeld()
- 它是否真的告诉我是否WakeLock
获得了 a ,我是否需要进行此检查?