I also want to show exactly the same battery level information in my
app. Wonder if you have found the relevant code/solution so far?

On Jan 18, 10:53 am, Narseo Vallina <nar...@gmail.com> wrote:
> Hi, all
>
> I'm trying to obtain thebatterytemperature, thebatteryvoltage and
> thebatterycurrent. The return value of the code (see below) for
> voltage and batteryTemperature is always 0 while the others work. I
> would like to know if there's any other way of obtaining thisinformation and 
> how. Finally, I couldn't find anything in the API 
> foraccessingthebatterycurrent... Is there any method to know its
> value?
>
> Many thanks in advance,
>
>         private BroadcastReceiver battReceiver = new BroadcastReceiver(){
>                 //StringBuilder sb = new StringBuilder();
>
>                 @Override
>                 public void onReceive(Context context, Intent intent) {
>                         Log.e("BATTERY_STATS", "onReceive. Changed Value");
>                         // TODO Auto-generated method stub
>                         context.unregisterReceiver(this);
>
>                         int rawlevel = intent.getIntExtra("level", -1);
>                         int scale = intent.getIntExtra("scale", -1);
>                         int status = intent.getIntExtra("status", -1);
>                         int voltage = intent.getIntExtra("voltage", -1);
>                         int batteryTemperature = 
> intent.getIntExtra("temperature", -1);
>
>                         if (status>=1){
>                                 status=1;
>                         }
>
>                         int level = -1;
>
>                         if (rawlevel >=0 && scale >0){
>                                 level = (rawlevel*100)/scale;
>                         }
>
>                         String batteryTechnology = 
> intent.getStringExtra("technology");
>
>                         //SAVE VALUES
>                 }
>         };

-- 
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