Androids Calendar.MINUTE does not return the correct Minute -
so have loop want poll data every 5 minutes keep api requests down minimum. problem currentmin not update when minute on android phone does. starts off correct fails stay current. ideas how can make poll data every 5 minutes?
while (x==false) { currentmin= c.get(calendar.minute); //get current min system.out.println(currentmin); if (currentmin%5==0) {//poll data every 5 min ***poll data*** } }
from how run method every x seconds:
use handler
. never, , mean never schedule tasks while
in android. battery dry within minutes, lock ui , make application slow.
handler h = new handler(); int delay = 1000; //interval in milliseconds h.postdelayed(new runnable(){ public void run(){ //pool data h.postdelayed(this, delay); } }, delay);
Comments
Post a Comment