android-wake-lock

Inquiry related to AlarmManager and WakeLocks

不问归期 提交于 2019-12-11 06:53:43
问题 I am developing a native android app that run a backup operation every 30 mins. I am using AlarmManager for this purpose and it works fine. Here is the code I am using to start the alarm: public static void startSync(Context context) { alarmIntent = new Intent(context, AlarmReceiver.class); pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0); manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // int interval = 3600000; int interval =30000 ; manager

What exact functionality stops working if a wake lock is not acquired and the device goes into sleep?

末鹿安然 提交于 2019-12-10 23:36:16
问题 The last couple of days I've been trying to figure out which functionality in a service (background and foreground) stops working when the device falls into sleep without a wake lock. All the documentation only says that a wake lock "keeps the CPU from shutting down", but every single functionality I've tested kept working without a wake lock if I turned the screen off and unplugged the device. I've also checked via adb if another application is holding a wake lock, but the wake lock count is

What happens with the partial wake lock if the process that acquires is killed?

不羁的心 提交于 2019-12-10 20:41:26
问题 Does it get released automatically if the process didn't released before it was killed? 回答1: The wakelock is released if Process is killed. You can check this by below method Acquire a wakelock and then run adb shell dumpsys power kill the process from ddms. Again run dumpsys power You can see that the mlocks.size is back to 0. 来源: https://stackoverflow.com/questions/12296767/what-happens-with-the-partial-wake-lock-if-the-process-that-acquires-is-killed

Android turn on the screen

巧了我就是萌 提交于 2019-12-10 19:30:48
问题 I making the application where an activity launch is scheduled by AlarmManager. I would like to appear even if the screen is turned off and device is locked. To achive this a set the Window flags final Window win = getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK

Android - When using LocationManager.requestLocationUpdates, do I need a WakeLock?

折月煮酒 提交于 2019-12-09 08:40:53
问题 My app periodically checks the location using an alarm to a BroastcastReceiver that starts a service. I know I should acquire a wakelock before I start the service but my question is when can I release it? If I release the wakelock after calling requestLocationUpdates , can the device go to sleep and not call my LocationListener or will the device always wake to deliver updates and stay awake until the callback has returned? I'm reluctant to hold onto the wakelock because that would prevent

Firebase and wake locks issue in Android

最后都变了- 提交于 2019-12-08 13:18:46
问题 I'm using several Firebase products in an Android app: compile 'com.google.firebase:firebase-core:11.0.1' compile 'com.google.firebase:firebase-database:11.0.1' compile 'com.google.firebase:firebase-storage:11.0.1' compile 'com.google.firebase:firebase-auth:11.0.1' compile 'com.google.firebase:firebase-messaging:11.0.1' One or more of these products seems to be using the WAKE_LOCK permission. Possibly Analytics or FCM. I can understand where it's needed. The problem however is that in the

Android strange cross device behaviour

送分小仙女□ 提交于 2019-12-08 06:08:49
问题 I have three android devices, a Samsung Galaxy Note 10 an HTC Desire C and a Sony Xperia E. As well i have a service that listens on a specific TCP port on these devices. The WIFI policy is set to "Always on" in all of my devices as well my service acquires a WIFI_MODE_FULL and a PARTIAL_WAKE_LOCK so the CPU and WIFI are always there. After some time when i want to connect to these devices from the server something bad happens. The Samsung Galaxy Note device always behaves correctly. HTC

Check for wifi networks signal in sleep mode

℡╲_俬逩灬. 提交于 2019-12-08 05:00:55
问题 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: registerReceiver(wifiReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION)); 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

Start activity even when screen is turned off

天大地大妈咪最大 提交于 2019-12-08 04:58:40
问题 I'm trying to start an activity with an alarm. The PendingIntent starts a receiver and the receiver starts the activity. My current issue is that the activity starts in the background and it's impossible to hear the alarm sound. Most of the flags from older SO questions are deprecated for Oreo and newer devices. Does anyone have a good approach how to handle this? Thank you in advance Alarm creation: alarmManager.setExact(AlarmManager.RTC_WAKEUP, intervalFinished, pendingIntent) Receiver

Does service.startForeground imply wakelock?

随声附和 提交于 2019-12-07 15:55:31
问题 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