0

Ok im making a live wallpaper for android and i want the change the fish im displaying depending on what time of day it is. so i adding this into the looping thread

public static int getCurrentHour() {
    // TODO Auto-generated method stub
    //i set getfishcolor
    int getFishColor = 0;
    final Calendar c = Calendar.getInstance();
    int t = Calendar.AM_PM;
    final int h = Calendar.HOUR;
    int theHour = c.get(h);
    int isAM = c.get(t);
    //check the time to see what type it should be
    if (theHour + isAM == 8 + isAM)
    { getFishColor = 0;}
    //this is then called in current_fish
    else {getFishColor = 4;}
    //restart loop somehow
        return getFishColor;
}

The problem is the render(); in the main class only runs once so if its already set the fish don't change but when i try to add it to my if statement it says it cant be static. how should i implement this code so its not static?

1 Answers1

0

Just put this code after you unlock the canvas. There is no need of static for this. Assuming you are calling canvas persec/putted logic to call it manytimes.

Ravi Bhojani
  • 1,032
  • 1
  • 13
  • 24