public class Main extends Activity {
  private TextView contentTxt;
  private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
    @Override
    public void onReceive(Context arg0, Intent intent) {
      // TODO Auto-generated method stub
      int level = intent.getIntExtra("level", 0);
      contentTxt.setText(String.valueOf(level) + "%");
    }
  };

  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    contentTxt = (TextView) this.findViewById(R.id.monospaceTxt);
    this.registerReceiver(this.mBatInfoReceiver, 
    new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
  }
}