Back to project page android-uds.
The source code is released under:
MIT License
If you think the Android project android-uds listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.imazlwifu.uds.model; /* w w w. j ava 2 s.com*/ import java.util.HashMap; import java.util.Map; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; public class Battery implements Monitorable { public final static String NAME = "Battery"; private Map<String, Float> values; private Context context; public Battery( Context context ) { this.context = context; values = new HashMap<String, Float>(); } @Override public void updateData() { Intent battery = context.registerReceiver( null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED) ); Bundle extras = battery.getExtras(); for( String s : extras.keySet() ) if( !s.contains( "icon" ) ) try { float f = (Integer) extras.get( s ); values.put( "Battery "+s, f ); } catch( Exception e ) {} } @Override public String getName() { return NAME; } @Override public Map<String, Float> values() { return values; } @Override public boolean registerListener() { // nothing to register return false; } @Override public void unregisterListener() {} }