Fields Summary |
---|
private android.widget.TextView | mStatus |
private android.widget.TextView | mLevel |
private android.widget.TextView | mScale |
private android.widget.TextView | mHealth |
private android.widget.TextView | mVoltage |
private android.widget.TextView | mTemperature |
private android.widget.TextView | mTechnology |
private android.widget.TextView | mUptime |
private com.android.internal.app.IBatteryStats | mBatteryStats |
private android.os.IPowerManager | mScreenStats |
private static final int | EVENT_TICK |
private android.os.Handler | mHandler |
private android.content.IntentFilter | mIntentFilterListens for intent broadcasts |
private android.content.BroadcastReceiver | mIntentReceiver |
Methods Summary |
---|
public void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
setContentView(R.layout.battery_info);
// create the IntentFilter that will be used to listen
// to battery status broadcasts
mIntentFilter = new IntentFilter();
mIntentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
public void | onPause()
super.onPause();
mHandler.removeMessages(EVENT_TICK);
// we are no longer on the screen stop the observers
unregisterReceiver(mIntentReceiver);
|
public void | onResume()
super.onResume();
mStatus = (TextView)findViewById(R.id.status);
mLevel = (TextView)findViewById(R.id.level);
mScale = (TextView)findViewById(R.id.scale);
mHealth = (TextView)findViewById(R.id.health);
mTechnology = (TextView)findViewById(R.id.technology);
mVoltage = (TextView)findViewById(R.id.voltage);
mTemperature = (TextView)findViewById(R.id.temperature);
mUptime = (TextView) findViewById(R.id.uptime);
// Get awake time plugged in and on battery
mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));
mScreenStats = IPowerManager.Stub.asInterface(ServiceManager.getService(POWER_SERVICE));
mHandler.sendEmptyMessageDelayed(EVENT_TICK, 1000);
registerReceiver(mIntentReceiver, mIntentFilter);
|
private final java.lang.String | tenthsToFixedString(int x)Format a number of tenths-units as a decimal string without using a
conversion to float. E.g. 347 -> "34.7"
int tens = x / 10;
return new String("" + tens + "." + (x - 10*tens));
|
private void | updateBatteryStats()
long uptime = SystemClock.elapsedRealtime();
mUptime.setText(DateUtils.formatElapsedTime(uptime / 1000));
|