battery

Obtaining usb cable plugged IN/OUT event using EXTRA_PLUGGED does not work

徘徊边缘 提交于 2019-12-01 03:16:59
问题 My intention is to have saved in Preferences current status of Android device usb/power cable: connected/disconnected. From Developer site I see that there are two Intent for obtaining that status: ACTION_POWER_CONNECTED / DISCONNECTED. So I used same code as published at Developers: http://developer.android.com/training/monitoring-device-state/battery-monitoring.html in section Monitor Changes in Charging State. Manifest <receiver android:name=".PowerConnectionReceiver"> <intent-filter>

ACTION_BATTERY_LOW not being fired from manifest?

旧街凉风 提交于 2019-12-01 00:45:53
Does action_battery_low allow being fired from the manifest because I thought it did? Here is my manifest for it: <reciever android:name=".BatteryReciever"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.BATTERY_LOW"/> </intent-filter> </reciever> But it never gets fired when I get the low battery warning from the system. Can this only be fired explicitly? Mr_and_Mrs_D The original question states that the receiver does not receive intents. This is because the receiver was declared as

Does the accelerometer drain battery on Android Wear? (Android watch)

五迷三道 提交于 2019-11-30 15:34:08
I'm creating an Android Wear app that tries to detect some of the hand movements, to do it, I need to continuously monitor the accelerometer output . I'm wondering how it will affect the battery life. For phones, I know that there are methods like "disable accelerometer while screen is turned off" to save battery, but what's the battery cost in case of watches? Since Android watch can count your steps and it turns on the screen when you face it towards your face, I believe the accelerometer is turned-on all the time anyway. in this case, will my app drain the battery? (Calculations after

Stopping and starting a Service based on application state

我们两清 提交于 2019-11-30 14:15:06
I have a Service which tracks the location of the user. Currently, the Service boots when the application starts and stops when the application terminates. Unfortunately, if users keep the application in the background, the Service never stops and drains battery. I would like the Service to stop when my application is not in the foreground. I was hoping the Application class would let me Override onPause and onResume handlers, but it does not have them. Is there another way I can accomplish this? I haven't tested this yet, but it looks like if you use Context#bindService() (instead of Context

Is location provider really a battery drain?

别来无恙 提交于 2019-11-30 10:23:18
I need to implement location-based service. I don't need fine location, so no GPS is needed. Easiest would be to start listening for locations updates at app start, and leave it ON: mLocationMgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 100, mPendingIntent); Since I don't need much accuracy, I set max frequency of updates, to 10s, and 100m instead of default 0, 0. When we think location, we think battery drain, but I guess this is a shortcut and that only GPS really drains the battery. I think that such a use of network provider wouldn't drain the battery. Any thoughts?

Getting Battery Health Information on iOS

人盡茶涼 提交于 2019-11-30 04:57:53
There are currently apps in the app-store (so it does not require jailbreak) that tell you : Exact percentage value of battery level you have on your iPhone. I have tried Apple's official Code Sample , although it tells you when your iPhone is charging and discharging but it gives me values in 5% steps. How do these apps get exact values of battery percentage ? Applications like Battery Health show Current Maximum Capacity vs Manufacturer's Capacity Current Discharge Rate Lifetime Battery Cycle Count The same application also gives information about the Charging Rate in Watts when the phone is

How does Android determine if an app has “High Battery Use” under “Recent Location Requests”?

空扰寡人 提交于 2019-11-29 23:16:16
As of Kitkat (4.4) Android reports that my app is "High battery use". I use Network Location as well GPS. If I disable GPS, then it seems the app gets marked as "Low battery use". I'm wondering if there are any tips to using GPS while keeping the "Low battery use" label. Perhaps if you poll infrequently enough - or is it hardcoded to GPS = battery killer? EDIT: I understand that changing those parameters will conserve battery life. My question was more of whether Android will recognize these attempts at battery life conservation or will it simply brand my app as high power usage simply because

Replacing the battery indicator (Android)

那年仲夏 提交于 2019-11-29 15:48:33
There's an open source battery indicator that I greatly prefer to the default one. I was wanting to modify it to replace the default battery indicator. Is this even possible without building a whole custom ROM? I do not believe it is possible without building a whole custom ROM. Yes, it is possible to do without building a new custom ROM, but you still need root access. the .png files for the battery indicator are in the framework-res.apk, you can extract that, replace just the .png files for the battery and put it back with approriate access rights and it will work. kinda like the process to

Checking battery level in the background with a service

廉价感情. 提交于 2019-11-29 15:47:16
问题 I've searched a lot but I'm always more confused. I have to create an app that works on background and checks the battery level. How can I create the Service? The Service should start on the device boot and must communicate with the Activity when the battery reaches a certain percentage, so there isn't any interaction from the consumer. What type of Service have I to create? What are the things I have to do? 回答1: Rather than using a long-running service, use an AlarmManager to trigger alarms

Battery broadcast receiver declared in manifest file does not work?

半城伤御伤魂 提交于 2019-11-29 14:23:50
There are two ways to make a broadcast receiver known to the system: One declares it in the manifest file with this element. The other is to create the receiver dynamically in java code. Now, the receiver has been created dynamically in java code and it does work normally.But why the first way "Declare in the manifest file" failed? Is there anyone to success? Thanks. AndroidManifest.xml <receiver android:name="pj.batteryinfo.BatteryReceiver"> <intent-filter> <action android:name="android.intent.action.BATTERY_CHANGED"></action> </intent-filter> </receiver> For some actions, you could only