wakelock

Partial wake lock is not working

我们两清 提交于 2021-02-19 03:36:15
问题 My application is having activities and background service which has to run 24*7 , My application has to talk to the server via Wi-Fi to send and receive the information. Problem: whenever any alarm send by the server my app should receive and pops up the app whether it is running in foreground or background and intimate to the user about the alarm. So when device is in active state this feature working perfectly but when device goes to sleep mode, after 1 or 2 mins it disconnects from the

Screen not turning on with wake lock in Android

一个人想着一个人 提交于 2021-02-08 05:12:12
问题 I have a foreground service that is waiting for a shake. When it receives that motion, it sends out a broadcast with: Intent i = new Intent("com.company.app.shakeDetectedMessage"); sendBroadcast(i); My main activity receives this with a broadcast receiver which implements the method: @Override public void onReceive(Context context, Intent intent) { MainActivity.this.turnOnScreen(); Toast.makeText(getApplicationContext(), "Screen ON", Toast.LENGTH_SHORT).show(); } And my turn on screen method:

Screen not turning on with wake lock in Android

纵然是瞬间 提交于 2021-02-08 05:05:08
问题 I have a foreground service that is waiting for a shake. When it receives that motion, it sends out a broadcast with: Intent i = new Intent("com.company.app.shakeDetectedMessage"); sendBroadcast(i); My main activity receives this with a broadcast receiver which implements the method: @Override public void onReceive(Context context, Intent intent) { MainActivity.this.turnOnScreen(); Toast.makeText(getApplicationContext(), "Screen ON", Toast.LENGTH_SHORT).show(); } And my turn on screen method:

Screen not turning on with wake lock in Android

点点圈 提交于 2021-02-08 05:04:51
问题 I have a foreground service that is waiting for a shake. When it receives that motion, it sends out a broadcast with: Intent i = new Intent("com.company.app.shakeDetectedMessage"); sendBroadcast(i); My main activity receives this with a broadcast receiver which implements the method: @Override public void onReceive(Context context, Intent intent) { MainActivity.this.turnOnScreen(); Toast.makeText(getApplicationContext(), "Screen ON", Toast.LENGTH_SHORT).show(); } And my turn on screen method:

Is it possible to hold multiple Wake Locks?

北城以北 提交于 2020-01-23 05:59:52
问题 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,

GPS location and deep sleep

半腔热情 提交于 2020-01-15 10:57:20
问题 I've got a foreground service (with START_STICKY so no problem for the aspect "killed by OS")that receive a location (GPS) update every 2 seconds for navigation purpose. I don't take any wakelock. My question is: have I to take a wakelock to avoid a deep sleep? Or the location updates is enough to be "running"? 回答1: After of bit of digging in Android code, the response is: no, you don't need it. Android will grab a wakelock for you (LocationManagerService) until onLocationChange ends or your

PowerManager.WakeLock on Android Devices

和自甴很熟 提交于 2020-01-14 10:46:48
问题 i am trying to implement an WakeLock in my Android App. I have the following code in my onCreat(): pm = (PowerManager) getSystemService(Context.POWER_SERVICE); myWakeLock = pm.newWakeLock(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,"WakeLock for Tuner"); The second line leading to a crash. It throws a Fatal Exception. As far as I can see Android says that the first Argument is no valid wake lock level. But on the developer Site it is recommended to use FLAG_KEEP_SCREEN_ON so i am a litte

Android service with long living HttpConnection

谁说胖子不能爱 提交于 2020-01-13 06:38:15
问题 I am tring to develop a project that connects to a comet server with long living connections. i do this job in a service. But when android device goes to idle mode, the thread i started from service stops working and do not close connections or try a new connection. is there any method that i should use for this stuff. 回答1: Using PowerManager.WakeLock solved my problem. I know, it kills baterry usage but, i had to use a long living service. 来源: https://stackoverflow.com/questions/5505801