Android Community
Results 1 to 2 of 2

Thread: Battery Value in Andriod

  1. #1
    Join Date
    Aug 2009
    Posts
    1

    Post Battery Value in Andriod


    Hi. Can anybody tell me how can I read Battery Value in Andriod Platform.

  2. #2
    Join Date
    Dec 2008
    Location
    Washington, DC
    Posts
    260

    Default Re: Battery Value in Andriod


    Here is some code posted a while back for creating a Battery Monitor

    package lol.peoplepaidforthis.BatteryMonitor;

    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 BatteryMonitor extends Activity
    {
    private TextView textView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    textView = (TextView)findViewById( R.id.condition );
    registerReceiver( batteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED) );
    }

    public void updateBatteryCondition(int level)
    {
    textView.setText( level + "%" );
    }

    private BroadcastReceiver batteryReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive( Context context, Intent intent )
    {
    int level = intent.getIntExtra( "level", 0 );
    updateBatteryCondition(level);
    }
    };
    }

Similar Threads

  1. Andriod stupidest thing
    By GREENie in forum General Phone Chat
    Replies: 20
    Last Post: 04-07-2009, 04:14 PM
  2. spotify needs to be on andriod
    By gpo1 in forum All About Andorid Software
    Replies: 3
    Last Post: 01-30-2009, 04:14 PM
  3. Where is the Andriod Community App!
    By hoobashoot in forum Developers Guild
    Replies: 14
    Last Post: 01-28-2009, 12:06 PM
  4. Voip For Andriod
    By adiprince1 in forum Developers Guild
    Replies: 8
    Last Post: 12-21-2008, 03:16 PM
  5. Just where can Andriod be gotten from?
    By GeekBoy in forum General Phone Chat
    Replies: 0
    Last Post: 03-06-2008, 10:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •