Código, status de batéria
27/04/2016
0
Fernando Ferreira
Posts
27/04/2016
Raylan Zibel
27/04/2016
Italo Junior
[url]http://stackoverflow.com/questions/3291655/get-battery-level-and-state-in-android[/url]
27/04/2016
Wolney Dias
public float getBatteryLevel() { Intent batteryIntent = registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); if(level == -1 || scale == -1) { return 50.0f; } return ((float)level / (float)scale) * 100.0f; }
30/04/2016
Fernando Ferreira
Clique aqui para fazer login e interagir na Comunidade :)