wakelock

Wakelock implementation in a service

[亡魂溺海] 提交于 2020-01-06 01:54:38
问题 I have a service that executes in 2 phones. They communicate with each other using sockets and execute some script (which may take 1-2 minutes approx.) and exchange files (using HTTP Post) between them. I want this execution to continue, even when the screen is off, i.e acquire a Wakelock. I saw this link, but I'm not sure where to incorporate this in my code(as the device may sleep in the mid of execution). Any guidance is highly appreciated. Thank you. 回答1: I m using same app for 2 phones.

BroadcastReceiver, Service and Wakelock

无人久伴 提交于 2020-01-02 05:13:28
问题 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. 回答1: 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

AlarmManager working well in emulator but not in real device

不问归期 提交于 2019-12-31 06:20:14
问题 this is my code for setting alarm: public void SetAlarm(Context context, int tag, long time){ AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, Alarm.class); i.putExtra("position", tag); PendingIntent pi = PendingIntent.getBroadcast(context, tag, i, PendingIntent.FLAG_CANCEL_CURRENT); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+ time, pi); // Millisec * Second * Minute } this is my onRecieve methode: public void

Android deep sleep and wake locks

≡放荡痞女 提交于 2019-12-30 12:03:14
问题 I have created an android app which runs fine in all phones. But in my Alcatel phone it doesn't as the phone goes to a deep sleep mode and the data network fails so the app doesn't get a data network and doesn't sync the data from the server . My Design ... SystemBootReceiver --> (DataSyncService)Service --> (MyBroadcastReceiver)BroadcastReceiver --> (MyDataService)Service . So here on system boot I start DataSyncService where I set up the AlarmManager (repeated) and call the

Dim screen while user inactive

两盒软妹~` 提交于 2019-12-30 08:16:11
问题 I have an app which is used for lets say 4 hours, but only every 5 minutes a user needs to make an input or read the screen. Putting the phone to sleep and locking the screen is a bit annoying. So I have two options: getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); which doesn't lock the screen but the screen is always bright, I would like to dim it while there is no activity. Just because of battery life span, or doesn't that matter that much for these 4 hours? a wake

Dim screen while user inactive

我们两清 提交于 2019-12-30 08:14:16
问题 I have an app which is used for lets say 4 hours, but only every 5 minutes a user needs to make an input or read the screen. Putting the phone to sleep and locking the screen is a bit annoying. So I have two options: getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); which doesn't lock the screen but the screen is always bright, I would like to dim it while there is no activity. Just because of battery life span, or doesn't that matter that much for these 4 hours? a wake

wifiLock and wakeLock not working correctly on Android

安稳与你 提交于 2019-12-29 08:48:07
问题 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

Turn off screen on Android

蓝咒 提交于 2019-12-27 10:21:35
问题 I am trying to turn on and off the display after a certain action happens (Lets just worry about turning the screen off for now). From what I understand from wake lock, this is what I have: PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag"); When I read other posts on stackoverflow and else where, they seem to tell me that PARTIAL_WAKE_LOCK will turn the screen off. But if I read the SDK

Cannot immediately connect to the server when android device is on sleep even though my app gets the PARTIAL_WAKE_LOCK at PowerManager (Sony Xperia)

岁酱吖の 提交于 2019-12-25 06:37:11
问题 [Abstract of my android app] My app monitors the server at fixed intervals (30 seconds). [Results(Issue)] 18[h] 00[m] 00[s] server check ok. 18[h] 00[m] 30[s] server check ok. 18[h] 03 [m] 14 [s] server check ok. <= This is issue. My app should check the server at 18:01:00. My app cannot connect the server at fixed intervals at Sony xperia. [Expected results] 18[h] 00[m] 00[s] server check ok. 18[h] 00[m] 30[s] server check ok. 18[h] 01 [m] 00 [s] server check ok. [About my program] My app

Turn the screen in to totally dark when press the button on the screen

本秂侑毒 提交于 2019-12-25 02:46:44
问题 How to code the android to turn the screen completely off just like you press the power button to lock your screen. I want the user to press the button on the screen and then screen goes off. I have tried (with permission): PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag"); wl.acquire(); but not working for me, please help! thank you! 来源: https://stackoverflow.com/questions/23432552/turn-the-screen-in-to-totally-dark