FileDocCategorySizeDatePackage
BatteryInfo.javaAPI DocAndroid 1.5 API7464Wed May 06 22:42:48 BST 2009com.android.settings

BatteryInfo

public class BatteryInfo extends android.app.Activity

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
mIntentFilter
Listens for intent broadcasts
private android.content.BroadcastReceiver
mIntentReceiver
Constructors Summary
Methods Summary
public voidonCreate(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 voidonPause()

        super.onPause();
        mHandler.removeMessages(EVENT_TICK);
        
        // we are no longer on the screen stop the observers
        unregisterReceiver(mIntentReceiver);
    
public voidonResume()

        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.StringtenthsToFixedString(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 voidupdateBatteryStats()

        long uptime = SystemClock.elapsedRealtime();
        mUptime.setText(DateUtils.formatElapsedTime(uptime / 1000));