batterymanager

Foreground service is killed in Android 10

醉酒当歌 提交于 2020-06-17 13:13:05
问题 In Android 10, some manufacturer comes with the new feature in a battery optimization setting (see the picture). My foreground service getting killed by OS after some time when the screen is off. I have used the foreground service with notification. This code is working well when the screen is ON in all devices. I am facing this issue in OnePlus and realMe device, both having an android 10 OS. I want to know, Is there any way to solve this problem? Is there any way to know in my device is

Where is the battery animation called from when wall charger connected to phone (OFF)?

江枫思渺然 提交于 2020-01-06 06:59:27
问题 I have Moto E (Rooted) which turn on when connected with USB via Laptop but not when connected to Wall charger instead it shows Battery animation. I got to know that battery animation is at framework-res.apk. Now I want to know from where it is called so that i can change it as required. 回答1: Through my experience with this try the following files: /system/bin/lpm /system/bin/lpmkey Or the like. 来源: https://stackoverflow.com/questions/26583245/where-is-the-battery-animation-called-from-when

BatteryManager stats not working on Android

走远了吗. 提交于 2019-12-11 11:26:15
问题 I am trying to get the batter level using a BroadCastReceiver: int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0); int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 0); I have added the following permissions to the AndroidManifest.xml: <uses-permission android:name="android.permission.BATTERY_STATS" /> When I print the level and scale, I see the default value of 0. Are there additional settings to it? 回答1: Calculating Battery Level in %: You can find the current battery

Android BatteryManager returning 0 for all property-retrieval calls

可紊 提交于 2019-12-10 16:47:28
问题 I'm having trouble trying to access most of the stats from my Android device's battery such as BATTERY_PROPERTY_CAPACITY , BATTERY_PROPERTY_CHARGE_COUNTER or BATTERY_PROPERTY_CURRENT_AVERAGE . These properties are all clearly documented here: http://developer.android.com/reference/android/os/BatteryManager.html I have the following permission declared on my manifest: <uses-permission android:name="android.permission.BATTERY_STATS" /> I have a non-null BatteryManager instance: mBatteryManager

Can you manually fire ACTION_BATTERY_LOW?

大兔子大兔子 提交于 2019-12-10 11:37:05
问题 I'm relatively new to android programming but I'm told most applications have a receiver that will cut down on battery expensive activities when android fires ACTION_BATTERY_LOW. Android developing page says: public static final String ACTION_BATTERY_LOW Added in API level 1 Broadcast Action: Indicates low battery condition on the device. This broadcast corresponds to the "Low battery warning" system dialog. This is a protected intent that can only be sent by the system. Constant Value:

How to detect remaining battery power through android programming?

断了今生、忘了曾经 提交于 2019-12-06 12:58:47
问题 I am working on battery saver app. There I need to detect remaining battery. I have done following. public class HomeActivity extends Activity { TextView tv_battery; @Override public void onCreate(Bundle b) { super.onCreate(b); setContentView(R.layout.main); tv_battery = (TextView) findViewById(R.id.tv_battery); } @Override protected void onResume() { super.onResume(); registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_LOW )); } private BroadcastReceiver

Total Battery Capacity in mAh of device Programmatically

守給你的承諾、 提交于 2019-12-06 02:33:35
问题 I have tried powerprofile of Android....I have tried this code...but it gives me 1000 answer every time in all the devices... Is there any other way in android to get battery capacity... Eg.if mobile device capacity is 2000mAh it should return me 2000 public Double getBatteryCapacity() { Object mPowerProfile_ = null; double batteryCapacity = 0; final String POWER_PROFILE_CLASS = "com.android.internal.os.PowerProfile"; try { mPowerProfile_ = Class.forName(POWER_PROFILE_CLASS) .getConstructor

How to get percentage of battery usage by each app in android programatically

让人想犯罪 __ 提交于 2019-12-05 02:38:41
问题 I am making a demo for battery usage percentage by all apps.I am able to get the total available battery percentage but want to get battery usage by percentage by each app separate.So Is there any way to do so as lot many apps are available in market.Please help or suggest to save newbie. 回答1: Only battery usage screen in Settings, where you can see battery usage of each application. There is no API or command-line way to get this information. See similar question discussion in stackoverflow

How to detect remaining battery power through android programming?

微笑、不失礼 提交于 2019-12-04 20:23:27
I am working on battery saver app. There I need to detect remaining battery. I have done following. public class HomeActivity extends Activity { TextView tv_battery; @Override public void onCreate(Bundle b) { super.onCreate(b); setContentView(R.layout.main); tv_battery = (TextView) findViewById(R.id.tv_battery); } @Override protected void onResume() { super.onResume(); registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_LOW )); } private BroadcastReceiver mBatteryReceiver = new BroadcastReceiver(){ @Override public void onReceive(Context ctxt, Intent intent) { int level =

Does anyone know whether the Android addProximityAlert on the LocationManager is battery intensive

*爱你&永不变心* 提交于 2019-12-04 14:10:09
问题 I just basically want to add about 20 and sometimes 80 Proximity Alerts with no time expiration with a radius of around 500 meters. Just wondering whether by doing this will suck up the battery real quick? also would it make any difference by reducing the radius? 回答1: This will definitely eat your battery real quick. You never want to be setting more than a couple of proximity alerts in any case, the use-case you describe isn't really catered for in Proximity Alerts. Proximity Alerts should