wakelock

Android persistent socket connection rules

天大地大妈咪最大 提交于 2019-11-28 15:49:56
问题 I have been doing some testing for a custom push notification solution for Android devices using persistent sockets. I would like to share my findings and validate the results. Simple Description The applications runs a foreground service and establishes a connection with the server and maintains that connection via aggressive pinging (@ 10 secs interval). If the connection is ever detected as dead, the app keeps trying to reconnect indefinitely. The server sends notifications via duplex

How can I see which wakelocks are active

拟墨画扇 提交于 2019-11-28 15:49:12
For some reason my Android phone won't go to sleep. I assume that a wakelock is keeping it awake, but there is no way to tell which wakelocks are active. The running services doesn't list anything suspicious, and certainly nothing different from usual. So my questions are: Does Android definitely release wakelocks when a process ends? Is it possible an app was badly written and didn't release a wakelock before exiting? Is there any way to see the active wakelocks? This is what dumpsys power shows: $ dumpsys power Power Manager State: mIsPowered=true mPowerState=0 mScreenOffTime=226093 ms

sendMessage doesn't work properly (Wearable)

风流意气都作罢 提交于 2019-11-28 14:28:28
If I'm sending some bytes using sendMessage from Huawei p9 (Android 6.0) into Android Wear (Sony) the messages are not delivered if the screen of handheld device is turned off. The notifications inside wearable are not updated until the screen in the phone is turned on (in 1 minute)! Will setUrgent help? I already added the application in "list of granded applications" that can work while the screen is off. The application already works in WAKELOCK state. Is it a feature for all Android 6.0 and newer devices? IS IT POSSIBLE TO AVOID THIS? ANY CLUES? I've waste 3 days to find the solution To

Android: Keep camera-LED on after screen turns off

谁说我不能喝 提交于 2019-11-28 10:22:23
since i'm at the beginning with Android coding i hesitated to post my question, but now i'm at the point where i can't resist. I have a service which turns on the camera-LED onCreate: @Override public void onCreate() { // make sure we don't sleep this.pm = (PowerManager) getSystemService(Context.POWER_SERVICE); this.mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SleepLED"); this.mTimer = new Timer(); this.mTimerTask = new TimerTask() { public void run() { // turn on the LED setFlashlight(Camera.Parameters.FLASH_MODE_TORCH); mWakeLock.acquire(); } }; // Get the notification-service

Develop Alarm Application

时光总嘲笑我的痴心妄想 提交于 2019-11-28 07:26:29
问题 I'd like develop an Alarm Application. The application should work like this: launch it the activity show me the time I can set the alarm I can close the application when the alarm time comes , it starts an activity (even if the device is locked) I have tried to adapt this sample https://github.com/commonsguy/cwac-wakeful but I cannot launch an activity when the alarm time comes. I use this code to setup the alarm (for test I have inserted this code on an onCreate method of activity): Intent

Android - How can I wake up the phone from a hard sleep to take a picture?

人走茶凉 提交于 2019-11-28 06:36:43
I want to take pictures from the Android device's camera periodically over a matter of hours, to create a time lapse video effect. I set an Alarm Manager with an AlarmManager.RTC_WAKEUP flag set to start up a service every few minutes. The service holds a partial wakelock, does some work, and then calls a Broadcast Receiver through the Alarm Manager which starts up an Activity. The activity is created (or is resumed), turns on it's own wakelock, and sets up the camera preview surface. Once the surface is setup the SurfaceHolder listener's surfaceChanged() method is called, which finally takes

Correct pattern to acquire a WakeLock in a BroadcastReceiver and release it in a Service

会有一股神秘感。 提交于 2019-11-28 06:25:22
Even after a lot of research I am still not completely sure if the way how I implement a WakeLock for a Service started by a BroadcastReceiver is correct - even though it seems to work fine. The broadcast receiver gets intents sent to it from an alarm, so to start with, from the API docs of AlarmManager : If your alarm receiver called Context.startService(), it is possible that the phone will sleep before the requested service is launched. To prevent this, your BroadcastReceiver and Service will need to implement a separate wake lock policy to ensure that the phone continues running until the

How to make the Android device hold a TCP connection to Internet without wake lock?

好久不见. 提交于 2019-11-28 04:25:30
I want my application to be connected to server though the mobile connection, yet allowing the device to go into sleep mode. I expect it to wake up when IP packates arrives. How can this be done? How to receive "interrupts" from the Internet without draining battery? When you are blocked on a read from a tcp stream the device can go into a deep sleep and when tcp traffic comes in it will briefly wakeup the device, as soon as a bit is read in you start a wakelock until you have received the whole transmission then release it. Here is an example with web sockets, I've ran this app for over 12

Wake the device up when app prompts user

北城余情 提交于 2019-11-28 01:40:10
问题 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, WakeLock

孤人 提交于 2019-11-28 00:45:27
I am bit confused after going through the questions & answers in Stackoverflow about WakefulIntentService . I just would like to get some knowledge on this topics to make sure my understanding is correct, please feel free to correct me, if I am wrong. I built a small application, where I am using a background Service that keeps playing music whenever the user shakes the mobile. I tested after the device is locked and screen is turned off and it works as expected. What I am hearing from this forum , the service might turn off as soon the device goes to asleep. Is that true? In my case, it works