wakelock

How to disable power button?

夙愿已清 提交于 2019-11-27 23:49:47
Is it possible to override the functionality of the android power button ? I want to 'disable' the power button. My plan is to override the functionality of this button to do nothing ( {}; ) Well my main idea is to disable the turning the screen off. I want when someone press the power button nothing to happen. How can I do this ? Is it possible to override the functionality of the android power button ? I want to 'disable' the power button. Fortunately, this is not possible, except perhaps via custom firmware. It works on Cyanogenmod: http://review.cyanogenmod.com/#/c/18924/4/core/res

sendMessage doesn't work properly (Wearable)

三世轮回 提交于 2019-11-27 19:35:46
问题 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

Wake locks android service recurring

馋奶兔 提交于 2019-11-27 19:12:00
I have this application that needs to run a service (background) that beeps periodically. The phone needs to beep the entire day for 5 seconds every one minute (used a handler in the service). I have implemented this service which does this perfectly, but when the phone goes into deep sleep mode, the execution stops of this handler stops. Using this answer from the question in SO, I managed to use wake locks and it works fine. But when I explicitly put the phone in deep sleep mode, the handler stops executing. Where do I place the wakelock in the service. Code snippet below. public class

OnPause and OnStop() called immediately after starting activity

我的未来我决定 提交于 2019-11-27 17:36:14
I have an activity that needs to turn screen on(if offed) when it is started. So in onCreate, I have: this.getWindow().setFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); Using this with help of wakelock in broadcasr receiver , I am able to cause my activity to display whenever it is started from broadcast receiver. But problem is very strange

Bring app to front, turn on display and unlock from AlarmManager?

我是研究僧i 提交于 2019-11-27 13:18:14
问题 I want to turn on the display, unlock the phone and bring my app to the front, when the alarm I've set activates. public class CountDownAlarm extends BroadcastReceiver { public CountDownAlarm(){ } public CountDownAlarm(Context context, int timeoutInSeconds){ AlarmManager alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, CountDownAlarm.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent

Light up screen when notification received android

混江龙づ霸主 提交于 2019-11-27 11:42:15
I have a service running for my application to send notification every hour. This is working fine as i heard a sound and a vibration every hour because of my notification but i also want that my notification light up my screen as well. But i am unable to light up my screen when notification appears. Pradeep Sodhi PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); boolean isScreenOn = pm.isScreenOn(); Log.e("screen on.................................", ""+isScreenOn); if(isScreenOn==false) { WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK |PowerManager

PowerManager.PARTIAL_WAKE_LOCK android

依然范特西╮ 提交于 2019-11-27 09:50:32
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.POWER_SERVICE); final WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, wakelockName);

How can I see which wakelocks are active

旧街凉风 提交于 2019-11-27 09:36:07
问题 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

BroadcastReceiver Vs WakefulBroadcastReceiver

十年热恋 提交于 2019-11-27 06:29:05
Can somebody explain what the exact difference is between BroadcastReceiver and WakefulBroadcastReceiver ? In what situations would we have to use each Receiver class? Mehul Joisar 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 : It is guaranteed that CPU will stay awake until you fire completeWakefulIntent . Example:

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

不问归期 提交于 2019-11-27 05:40:19
问题 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