power-management

Battery status is always not charging

感情迁移 提交于 2019-12-01 16:31:14
问题 @Override public void onReceive(Context context, Intent intent) { int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_UNKNOWN); if (status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL) Toast.makeText(context, "Charging!", Toast.LENGTH_SHORT).show(); else Toast.makeText(context, "Not Charging!", Toast.LENGTH_SHORT).show(); } Manifest: <receiver android:name=".receiver.BatteryReceiver"> <intent-filter> <action

Animation in status bar in Android

穿精又带淫゛_ 提交于 2019-12-01 13:30:40
I'm new here in Android. I'd like to make a Battery Charging Animation in the phone, for example, in the top-right of the screen, the small icon that is moving upside down when charging and stops on a current battery percentage. So far in my code, I've been able to make it move, but it never stops. What I want is for the animation to stop when it is not charging or for it to stop on a current battery percentage. Here is my code in the animation : public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.batteryinfo); ImageView batteryImage =

Wakelock is not turning on the screen? Help?

淺唱寂寞╮ 提交于 2019-12-01 12:54:57
I have a signal that puts my app to sleep for a given number of minutes (using AlarmManager) and then wakes it back up. Everything is working except the screen doesn't ever come on. I'm using a wakelock like so from a BroadcastReceiver class: KeyguardManager key = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); KeyguardLock lock = key.newKeyguardLock(TAG); lock.disableKeyguard(); Log.v(TAG, "alarm: disabled keyguard."); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); gpsMain.wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, TAG);

Animation in status bar in Android

☆樱花仙子☆ 提交于 2019-12-01 11:58:58
问题 I'm new here in Android. I'd like to make a Battery Charging Animation in the phone, for example, in the top-right of the screen, the small icon that is moving upside down when charging and stops on a current battery percentage. So far in my code, I've been able to make it move, but it never stops. What I want is for the animation to stop when it is not charging or for it to stop on a current battery percentage. Here is my code in the animation : public void onCreate(Bundle savedInstanceState

Python Save Sets To File On Windows Shutdown?

落爺英雄遲暮 提交于 2019-12-01 11:51:19
问题 I do not want to lose my sets if windows is about to shutdown/restart/log off/sleep, Is it possible to save it before shutdown? Or is there an alternative to save information without worring it will get lost on windows shutdown? JSON, CSV, DB? Anything? s = {1,2,3,4} with open("s.pick","wb") as f: # pickle it to file when PC about to shutdown to save information pickle.dump(s,f) 回答1: you can detect windows shutdown/log off with win32api.setConsoleCtrlHandler there is a good example How To

What are the things which reduces (Android) battery time?

百般思念 提交于 2019-12-01 11:31:52
In one of our application we need to use the GPS continuesly ,the purpose is to get the user driving speed. Recently I found that while using the GPS continuesly can drain the device battery. If the GPS device is not used, device battery will work for hours but if the GPS is used it reduces the battery life dramatically. I was wondering that "what are other things" which can reduce the battery time? How we can avoid them ? What are the best practices to use them? Yaqub Ahmad Well i found the answer here, Google I/O 2009 - Coding for Life -- Battery Life, That Is What can I do to increase

Wakelock is not turning on the screen? Help?

纵饮孤独 提交于 2019-12-01 10:13:06
问题 I have a signal that puts my app to sleep for a given number of minutes (using AlarmManager) and then wakes it back up. Everything is working except the screen doesn't ever come on. I'm using a wakelock like so from a BroadcastReceiver class: KeyguardManager key = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); KeyguardLock lock = key.newKeyguardLock(TAG); lock.disableKeyguard(); Log.v(TAG, "alarm: disabled keyguard."); PowerManager pm = (PowerManager) context

What are the things which reduces (Android) battery time?

谁都会走 提交于 2019-12-01 08:09:16
问题 In one of our application we need to use the GPS continuesly ,the purpose is to get the user driving speed. Recently I found that while using the GPS continuesly can drain the device battery. If the GPS device is not used, device battery will work for hours but if the GPS is used it reduces the battery life dramatically. I was wondering that "what are other things" which can reduce the battery time? How we can avoid them ? What are the best practices to use them? 回答1: Well i found the answer

Estimated battery time on iOS [duplicate]

守給你的承諾、 提交于 2019-12-01 06:13:57
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: iphone: Calculating battery life I have seen many apps in appstore which provides Estimated battery work time for different usage patterns (standby, audio and video playback, Wi-Fi and 3G browser usage, talk time). I have a similar requirement to compute the estimated time like this. Can someone throw some light on how to do this programmatically? 回答1: The battery life specs come from Apple's site. Talk time:

Read Magic Mouse and Apple Wireless Keyboard Battery percentage

假如想象 提交于 2019-12-01 05:15:23
问题 I want to ask you If anybody know a simple way to access Mouse and Keyboard battery state in Mac OS. There are some API to access this information? Thanks! 回答1: For the Keyboard it is: ioreg -n "IOAppleBluetoothHIDDriver" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g' and for the Magic Mouse it is: ioreg -n "BNBMouseDevice" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g' 来源: https://stackoverflow.com/questions/3547797/read-magic-mouse-and-apple-wireless-keyboard-battery-percentage