http://i-learnedandroid.blogspot.com/
  this source code is to read battery state and view it.










import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.TextView;
 public class extends Activity (batteryInformation

         private TextView batteryTxt;
         private BroadcastReceiver BroadcastReceiver mBatInfoReceiver = new () (

           @ Override

              public void onReceive (Context arg0, Intent intent) (

                     / / TODO Auto-generated method stub
                    int level = intent.getIntExtra ("level", 0); //get the 
level 
battery
                    batteryTxt.setText (String.valueOf (level) + "%");
              )
         );

          @ Override

         public void OnCreate (Bundle Icicle) (
           super.onCreate (Icicle);
           setContentView (R.layout.main);
           batteryTxt = (TextView) this.findViewById (R.id.TextView01);
           this.registerReceiver (this.mBatInfoReceiver,
           New IntentFilter (Intent.ACTION_BATTERY_CHANGED));
         )


      

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to