wakelock

Turning screen on and off programmatically not working on some devices

好久不见. 提交于 2019-12-23 01:45:16
问题 I use the code below to turn the screen on and off. Both pieces of code work on most devices (tested on Galaxy Note, Galaxy S2, etc. etc.) but don't work on a few (mostly tablets but some phones as well). On some devices screen on works but screen off doesn't, and the opposite holds for some other devices. I'm not sure what the cause is since it's pretty standard code (and since it works on some devices that means triggering these functions i.e. the function call, is not a problem). Are there

Wake phone from unlock screen android

孤街醉人 提交于 2019-12-22 10:28:31
问题 Hеllo guуs, I want to unlock the phone with service. I'm using alarm manager. Receiver and Service were added to manifest and also permissions for RECEIVE_BOOT_COMPLETE and WAKE_LOCK AlarmReceiver public class AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { setAlarms(context); } public static void setAlarms(Context context) { cancelAlarms(context); PendingIntent pIntent = createPendingIntent(context); Calendar calendar = Calendar

Should I call WakeLock before creating a notification?

拟墨画扇 提交于 2019-12-21 17:05:58
问题 I'm adding notifications to an Android app and only have the emulator to test with at the moment. When a notification is received, my onMessage() method in my GCMBaseIntentService subclass (GCMIntentService) is called. From here I create a notification to appear. If I turn the emulator on standby, no notification is seen (I do t know if it would be heard on a device?). So should I be calling WakeLock to wake the device before creating the notification? Thanks 回答1: I'm not sure if the emulator

Aquire partial wakelock in a IntentService

谁都会走 提交于 2019-12-20 07:37:51
问题 My IntentService gets fired from 2 places, either by an Alarm or by the Activity and since the duration is related to the amount of data it needs do fetch from the web, from what I understood, I need to keep a partial wakelock. Here's my implementation: @Override protected void onHandleIntent(Intent intent) { PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WakeLock"); try { wakeLock.setReferenceCounted(false

WakeLock not working

流过昼夜 提交于 2019-12-20 01:45:48
问题 I have a wake lock set up so that I can still hear the sound when the screen times out or I press the screen lock button. From what I can understand through reading online is that I only need a partial wake lock. Here is the code but it is not working. No logcat errors package com.androidsleepmachine.gamble; import android.app.Activity; import android.content.Context; import android.media.MediaPlayer; import android.os.Bundle; import android.os.Handler; import android.os.PowerManager; import

How to keep android device from sleeping while plugged in

久未见 提交于 2019-12-20 01:34:51
问题 I'd like to keep the screen on whenever one of my Activities are running and the phone is plugged in to a power source. I know that Wakelocks are tricky, so I'm looking for an example or some documentation on how to accomplish this specific goal. 回答1: Don't use wake locks for this -- just set and clear the window flag WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON based on whether the device is currently plugged in. You can set the flag with Activity.getWindow().addFlags() . So the code would

Android WifiLock not working?

依然范特西╮ 提交于 2019-12-19 12:05:28
问题 I need to pull data from a server on the local network every x minutes via WiFi and HTTP. A Service is running in the Background and I use an AlarmManager to trigger the query. Wifi Sleep Policy is set to "never" on the device. Problem is, the device goes to sleep when the screen is off and the wifi lock does not seem to reconnect the wifi properly, so the query fails. Any idea what is wrong here ? Exectution {...} wakeLockUtil.lock(); //wait for wifi to connect (no idea if this is useful)

PARTIAL_WAKE_LOCK vs SCREEN_DIM_WAKE_LOCK in download thread

天涯浪子 提交于 2019-12-18 15:47:25
问题 I have a service that spawns a download thread that downloads sometimes large files. I realized that as soon as the phone went to sleep, the download thread would slow down significantly, then stop. The obvious remedy, a wakelock. So I would think that it would be ok to acquire a partial_wake_lock, just to keep the cpu processing the download. That doesn't work though, same behavior, the download slows and then stops when the screen turns off. Then I tried a screen_dim_wake_lock. This time,

Does the Android OS release a wakelock if the app or service holding it is killed?

只愿长相守 提交于 2019-12-18 10:16:36
问题 I have question about wakelock. In cases shown below, does android OS release wakelock ( PARTIAL_WAKE_LOCK if you need to specify) to prevent wakelock was left acquired and wasting battery until turning power off (not sleep). Case 1-a: App has acquired wakelock (w/o timeout option) in one of its threads (please think it is reasonable in this case) and it was designed to release wakelock when critical task was finished. App can be killed by taskmanager or notorious taskkiller, and app has no

Keep a Service running even when phone is asleep?

允我心安 提交于 2019-12-17 03:51:08
问题 I have a Service in my application which is designed to run every 10 minutes. It basically checks up on our servers to see if everything is running properly and notifies the user of any problems. I created this application for internal use at our company. My co-worker used the application over the long weekend and noticed that no checks were performed when the device went to sleep. I was under the impression that the Service was supposed to keep running in the background until I explicitly