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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -