Android app: How do change the battery percentage? -
i'd access battery details i'll able change it. example, display 80% battery instead of 50%.
how access in code?
thanks in advance! dvir
private handler handler = new handler; private broadcastreceiver mbatinforeceiver = new broadcastreceiver() { @override public void onreceive(final context context, intent intent) { int level = intent.getintextra(batterymenter code hereanager.extra_level, 0); int scale = intent.getintextra(batterymanager.extra_scale, 100); log.i(tag, "level: " + level + "; scale: " + scale); int percent = (level*100)/scale; final string text = string.valueof(percent) + "%";enter code here handler.post( new runnable() { public void run() { toast.maketext(context, text, toast.length_short).show(); } }); } };
Comments
Post a Comment