android - is my do loop code for java correct? -
is correct? im modifying source code github : usb charge commander when battery goes down 20 percent charge when batter goes 80 wont , countdown timer every 5 mins set 20000 testing
boolean startcountdown=true; do{ new countdowntimer(20000, 1000) { intent intent = _context.registerreceiver(null, new intentfilter(intent.action_battery_changed)); int level = intent.getintextra(batterymanager.extra_level, 0); int scale = intent.getintextra(batterymanager.extra_scale, 100); int percent = (level*100)/scale; public void ontick(long millisuntilfinished) {} public void onfinish() { if(percent <= 20){ _iischarging = 1; } else if (percent >=80){ _iischarging = 0; } else{ _iischarging = 1; } } }.start(); }while(startcountdown);
there no way do/while loop end, it's infinite loop @ moment. boolean "startcountdown" needs way go value of false. example
if (_iischarging == 0) { startcountdown = false; }
Comments
Post a Comment