wakelock

Activity Recognition does not work after phone goes asleep

∥☆過路亽.° 提交于 2019-11-30 19:41:11
问题 Disclaimer: this is not duplicate of Activity Recognition stops receiving updates when phone goes to standby(screen off state) because I'm already using that approach and it does not help. Problem: It seems that Activity Recognition service stops working and is not sending any updates when device goes asleep. It works OK (recognized activities are stored to sqlite) when device is not asleep but as soon as I press power button on HTC M8, nothing is stored from this moment until I wake up the

Battery optimizations (wakelocks) on Huawei EMUI 4.0+

 ̄綄美尐妖づ 提交于 2019-11-30 16:57:19
问题 Good day, situation: I'm developing Android application that serve as sport tracker/navigation app - so it require permanent connection to GPS and also permanent awake device. Recording is done every second. Current solution working for years is thanks to wakelocks that keep device awake. Doze mode in Android 6.0+ complicate situation, but it is not this case. On Huawei device is probably different type of optimization. Here is part of log: 10-10 10:33:18.462 1014-384 D/PFW

Wake up Android Phone/tablet?

≡放荡痞女 提交于 2019-11-30 08:41:56
问题 I've got a push notification-app, is there any way to wake up the screen (just make it light up) whenever I receive a push notification? if you want some code just let me know! and Thank you for your answers! 回答1: You can do it using a WakeLock this way: When you set your notification: WakeLock screenOn = ((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "example"); screenOn.acquire(); And, IMPORTANT ,

Using WakeLock to Keep A Stream Playing

匆匆过客 提交于 2019-11-30 07:30:30
问题 I have a MediaPlayer running in a Service that's playing audio from a URL (streaming). As of now it appears to work well, and even continues playing when I put the phone in standby. I currently do not acquire a wakelock. My question is: Is it actually necessary to acquire a wakelock in my situation? If it is necessary, what type of wakelock should I acquire? And yes, this is a legitimate use-case for wakelock, because my users explicitly want the audio to continue playing. 回答1: MediaPlayer

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

一曲冷凌霜 提交于 2019-11-29 20:35:27
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 chance to let its thread release wakelock. What happens to that wakelock? Case 1-b: (If answer to case 1

wifiLock and wakeLock not working correctly on Android

故事扮演 提交于 2019-11-29 15:14:42
I am developing an app that needs to use both wifiLock and wakeLock so the audio streaming when the screen is off does not get disturbed. I have tried my app on Android 2.3 and wakeLock and looks like wifiLock work as expected so there is no difference between when the screen is on or off, but the same app on Android 4.2 (Jelly-bean) when the screen goes off is not working as well and the audio gets choppy which shows either wakeLock or wifiLock are not working correctly. Is there any reason for this? Here is how I acquire and release the locks, in my main activity I have: @Override public

Wake the device up when app prompts user

戏子无情 提交于 2019-11-29 08:10:25
I'm using handler to repeatedly prompt user for an input every e.g. 5 minutes. When the device goes into sleeping mode and screen is locked, how can I wake the device up when my app prompts user for input? I've tried this but it doesn't seem to work. I've added WAKE_LOCK permission in the manifest. class BtHandler extends Handler { private PowerManager pm; private WakeLock wl; @Override public void handleMessage(Message msg) { pm = (PowerManager)FixedNode.this.getSystemService(Context.POWER_SERVICE); if (!pm.isScreenOn()) { wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "TAG"); wl.acquire();

Wake up Android Phone/tablet?

对着背影说爱祢 提交于 2019-11-29 07:36:22
I've got a push notification-app, is there any way to wake up the screen (just make it light up) whenever I receive a push notification? if you want some code just let me know! and Thank you for your answers! You can do it using a WakeLock this way: When you set your notification: WakeLock screenOn = ((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "example"); screenOn.acquire(); And, IMPORTANT , release the wakelock when you don't need it anymore: screenOn.release(); 来源: https://stackoverflow.com/questions

Using WakeLock to Keep A Stream Playing

自闭症网瘾萝莉.ら 提交于 2019-11-29 04:09:50
I have a MediaPlayer running in a Service that's playing audio from a URL (streaming). As of now it appears to work well, and even continues playing when I put the phone in standby. I currently do not acquire a wakelock. My question is: Is it actually necessary to acquire a wakelock in my situation? If it is necessary, what type of wakelock should I acquire? And yes, this is a legitimate use-case for wakelock, because my users explicitly want the audio to continue playing. MediaPlayer does not do this for you automatically by default. However, instead of you having to acquire a wake lock, it

Bring app to front, turn on display and unlock from AlarmManager?

不羁岁月 提交于 2019-11-28 20:55:13
I want to turn on the display, unlock the phone and bring my app to the front, when the alarm I've set activates. public class CountDownAlarm extends BroadcastReceiver { public CountDownAlarm(){ } public CountDownAlarm(Context context, int timeoutInSeconds){ AlarmManager alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, CountDownAlarm.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); Calendar time = Calendar.getInstance(); time.setTimeInMillis(System