power-management

Do android broadcast receivers consume battery life?

最后都变了- 提交于 2019-12-30 09:33:11
问题 I have two receivers that are listening for android.intent.action.BOOT_COMPLETED and android.intent.action.PACKAGE_REPLACED . I was wondering how much battery life they are causing my phone to consume since they cause my app to constantly run now. 回答1: The broadcast receivers themselves will not directly consume much battery life. BOOT_COMPLETED happens once; PACKAGE_REPLACED happens only on an application upgrade. Those probably average one event per day. Now, if those broadcast receivers do

Do android broadcast receivers consume battery life?

不打扰是莪最后的温柔 提交于 2019-12-30 09:32:18
问题 I have two receivers that are listening for android.intent.action.BOOT_COMPLETED and android.intent.action.PACKAGE_REPLACED . I was wondering how much battery life they are causing my phone to consume since they cause my app to constantly run now. 回答1: The broadcast receivers themselves will not directly consume much battery life. BOOT_COMPLETED happens once; PACKAGE_REPLACED happens only on an application upgrade. Those probably average one event per day. Now, if those broadcast receivers do

How do I wake from display sleep in OSX 10.7.4?

纵饮孤独 提交于 2019-12-29 08:12:39
问题 In the most recent version of OSX Lion, how do you wake up the machine from display sleep? This is in response to network activity. In 10.7.3 this was possible with the following call: IOPMAssertionID id = 0; IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reason, &id) However, this does not work in 10.7.4. What can be done instead? 回答1: I have not yet tested the performance implications nor the interaction with the idle timer itself, but: io_registry

Android: Battery usage of each application

不羁的心 提交于 2019-12-29 00:59:28
问题 Is there anyway to get the battery usage info per application per second in API, adb shell, ...? 回答1: Other than the battery usage screen in Settings, there is no API or command-line way to get this information. 回答2: just try to read http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/1.6_r2/com/android/settings/fuelgauge/PowerUsageSummary.java/ , then you can get the info shown in the battery usage screen. the key class are IBatteryStats and

Get the remaining battery time available from an Android phone

一笑奈何 提交于 2019-12-28 06:48:14
问题 Is it possible to get the remaining battery time available from an Android phone? Thanks. 回答1: You can get battery life with help of broadcast receiver by registering a receiver for action Intent.ACTION_BATTERY_CHANGED . My answer is key only, get information from Android Developers website. By using the below statement in onReceive() method of BroadcastReceiver with above Intent action, you will get battery level currently available(e.g., 50%, 60%, etc.). But you can't estimate the time

Correct method for setKeepScreenOn / FLAG_KEEP_SCREEN_ON

好久不见. 提交于 2019-12-28 03:35:07
问题 I am using the method setKeepScreenOn(true) and haven't been able to figure out how to call this in relation to the current Activity (which has a content view set). I've been able to get it to work by calling it on one of my buttons which is always present in the view, but this feels wrong - and I'm sure there must be a way to get around this. I tried referencing the current focus like this: getCurrentFocus().setKeepScreenOn(true); but that threw a NullPointerException. Maybe there was no

How to get the Battery Charge Level specifically in mWh (not percentage) for Mac (Cocoa or C)

主宰稳场 提交于 2019-12-23 17:12:07
问题 The title pretty much explains it all. I'm creating a mac app and I need the battery charge level specifically in mWh (not percentage). Would like to do it in C or Objective C preferably. Thanks! 回答1: Sorry, but I don't think the hardware has a way to report that. It's going to change over time as the battery gets on in its life cycle, and all you could know at the outset is the nominal capacity of the battery when it was installed. 回答2: So here is a bit of code that directly answers my

Power Management Notifications in Linux

风格不统一 提交于 2019-12-23 15:22:10
问题 Which are the approach (simplest possible) that we can use to get notified for Power Status changes (for instance when computer goes to sleep, hibernate, etc.) in Linux based systems? I will need this mainly for persisting some state before sleeping, and of course, restoring that state once the computer wakes up. 回答1: You can get all these events by just configuring your acpid to send them via socket, for example. There's an official specification document that describes all possible events

Battery broadcast receiver doesn't work

末鹿安然 提交于 2019-12-23 05:59:31
问题 I don't know why, but my battery broadcast receiver doesn't work. AndroidManifest.xml <receiver android:name=".BatteryReceiver" android:enabled="true"> <intent-filter> <action android:name="android.intent.action.BATTERY_CHANGED" /> <action android:name="android.intent.action.BATTERY_LOW" /> </intent-filter> </receiver> BatteryReceiver.java public class BatteryReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { int level = intent.getIntExtra(

Battery broadcast receiver doesn't work

最后都变了- 提交于 2019-12-23 05:59:11
问题 I don't know why, but my battery broadcast receiver doesn't work. AndroidManifest.xml <receiver android:name=".BatteryReceiver" android:enabled="true"> <intent-filter> <action android:name="android.intent.action.BATTERY_CHANGED" /> <action android:name="android.intent.action.BATTERY_LOW" /> </intent-filter> </receiver> BatteryReceiver.java public class BatteryReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { int level = intent.getIntExtra(