wakelock

Keep a Service running even when phone is asleep?

寵の児 提交于 2019-11-26 17:03:00
I have a Service in my application which is designed to run every 10 minutes. It basically checks up on our servers to see if everything is running properly and notifies the user of any problems. I created this application for internal use at our company. My co-worker used the application over the long weekend and noticed that no checks were performed when the device went to sleep. I was under the impression that the Service was supposed to keep running in the background until I explicitly call stopService() in my code. So ultimately, my goal is to have the service running until the user hits

PowerManager.PARTIAL_WAKE_LOCK android

风流意气都作罢 提交于 2019-11-26 14:55:29
问题 I am very confused whether to acquire this wakelock. E.g. I have this type of code that is called from onReceive() of a BroadcastReceiever (CONNECTIVITY_CHANGE, BOOT_COMPLETED etc) asynchronously i.e. I am launching an IntentService from onReceive() which performs heavy lifting. private static void insertInDatabase(Context context /*, some data to be inserted in database*/) { Database helper = Database.getInstance(context); PowerManager pm = (PowerManager) context .getSystemService(Context

BroadcastReceiver Vs WakefulBroadcastReceiver

女生的网名这么多〃 提交于 2019-11-26 12:02:07
问题 Can somebody explain what the exact difference is between BroadcastReceiver and WakefulBroadcastReceiver? In what situations would we have to use each Receiver class? 回答1: There is only one difference between BroadcastReceiver and WakefulBroadcastReceiver . When you receive the broadcast inside onReceive() method, Suppose, BroadcastReceiver : It is not guaranteed that CPU will stay awake if you initiate some long running process. CPU may go immediately back to sleep. WakefulBroadcastReceiver

Turn off screen on Android

a 夏天 提交于 2019-11-26 08:09:40
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 it says that it will only allow the screen to be turned off. So I think this isn't right. Any hints