wakelock

Alarm Manager won't work when the app is killed in the background and device is locked

China☆狼群 提交于 2019-12-06 05:42:24
问题 I have been stuck in this situation for a long time... I want to use the alarm manager to show notification at the specific time, and now it worked in the situation listed below: when the app runs in the background, notification will be shown at the correct time, and no matter the device is locked or not. after the app has been killed in the background, i will still get correct notification when device is not locked, but things turn wrong when the device is locked, i can't receive any

Wake phone from unlock screen android

半城伤御伤魂 提交于 2019-12-06 03:19:29
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.getInstance(); setAlarm(context, calendar, pIntent); } @SuppressLint("NewApi") private static void

do I need a wake lock in my broadcastreceiver if I'm not starting a service or an activity?

我的未来我决定 提交于 2019-12-06 02:33:58
问题 I have a broadcastreceiver called by an Alarm (scheduled with AlarmManager). In this receiver I'm only querying a register from the database, and launching a notification. I readed that a wake lock is needed when a service or an activity is started from a broadcast receiver, but, do I need a wake lock if I only want to show a notificacion (in the notification panel)? 回答1: In this receiver I'm only querying a register from the database, and launching a notification. Do not do database I/O on

When will android stop its cpu without wake lock?

走远了吗. 提交于 2019-12-06 00:39:01
问题 I know android use wake lock to keep cpu running or screen on. It's obvious that screen wake lock prevents the user active timer from turning off the screen after a period of user inactivity. But I'm wondering when exactly will the cpu wake lock take effect. 1.If I create a new thread and keep draining cpu in background with out any wake lock, turn off the screen will not stop it. Will it stop and when will it stop? 2.What about a thread scheduled with Timer.schedule()? 3.It leads to another

Help with PROXIMITY_SCREEN_OFF_WAKE_LOCK in Android

允我心安 提交于 2019-12-06 00:30:52
问题 I've enabled the proximity wakelock in my app, and it turns off the screen when the proximity sensor detects something. But there is a problem when the screen wakes back up -- it goes to the lockscreen, not my app. This happens regardless of the time that the screen was off (even if the sensor is cleared after a few seconds). Here's the code I used: int PROXIMITY_SCREEN_OFF_WAKE_LOCK = 32; mProximityWakeLock = pm.newWakeLock(PROXIMITY_SCREEN_OFF_WAKE_LOCK, LOG_TAG); if(!mProximityWakeLock

Does service.startForeground imply wakelock?

只愿长相守 提交于 2019-12-05 21:13:20
Question I am wondering if we need to aquire the WakeLock or if the service.startForeground() command does that anyway for us? I didn't find anything in the documentation. Goal We want to remove unnesessary stuff which might slow down the service start as we want to start capturing the sensor data as soon as possible and as the service might be restarted frequently. Context We're developing an Android library to capture sensor data with ~ 200 Hz for up to a couple of hours (research environment). Right now we aquire a WakeLock and start the capturing service as ForegroundService to make sure

BroadcastReceiver, Service and Wakelock

别来无恙 提交于 2019-12-05 15:47:44
im receiving an intent in broadcast receiver and then i start service to do more work. now what if the device is sleep and this happen, do i have to get Wakelock (AlarmManger?), and why do i need it? does my service will stop running if the device goes to sleep without getting a wakelock. now what if the device is sleep and this happen, do i have to get Wakelock (AlarmManger?), and why do i need it? If the device is asleep to begin with, you will not be "receiving an intent in broadcast receiver", because the device is asleep. do i have to get Wakelock (AlarmManger?), and why do i need it? You

Is it possible to hold multiple Wake Locks?

蹲街弑〆低调 提交于 2019-12-05 04:28:33
I'm developing a small utility app that scans 2D barcodes, and then submits each barcode to an IntentService where a longer task is performed. When the activity is shown, it should prevent the device from sleeping, until the barcode is processed in the service. If the service finishes the processing, it stops itself, but the activity should still be visible. I'd like to hold a SCREEN_DIM_WAKE_LOCK WakeLock during the activity lifecycle, but as this type doesn't prevent the CPU from sleeping, I'd also need to acquire a PARTIAL_WAKE_LOCK in the activity when a new 2D code is scanned, and release

How to wake up an Android on incoming data

孤街浪徒 提交于 2019-12-04 11:45:11
I want an Android service, which is listening for data (I have tried TCP and UDP) to wake up the service/phone when data arrives. Currently the phone stays asleep when IP data arrives and that data is lost. Is this normal for Android? I see sleeps of 2+ hours several times a day, and 7+ hour sleeps when I am asleep. Does GCM provided a solution which wakes up a service/phone when a message arrives. I need messages to be displayed within a few seconds of them being sent from the server. Can this only be achieved by keeping the CPU running all day long? Is there no interrupt from the GSM modem

Alarm Manager won't work when the app is killed in the background and device is locked

我怕爱的太早我们不能终老 提交于 2019-12-04 11:22:00
I have been stuck in this situation for a long time... I want to use the alarm manager to show notification at the specific time, and now it worked in the situation listed below: when the app runs in the background, notification will be shown at the correct time, and no matter the device is locked or not. after the app has been killed in the background, i will still get correct notification when device is not locked, but things turn wrong when the device is locked, i can't receive any notification. Here's the code AlarmReceiver.java, all the needed permission has been added into