Java / Android Programming - Loop FAIL

后端 未结 3 494
温柔的废话
温柔的废话 2021-01-29 14:39

I am using a while loop with a timer. The thing is that the timer is not used in every loop. It is used only the first time. After the first time the statements included inside

3条回答
  •  无人共我
    2021-01-29 15:36

    It's because you're queueing up 10 toasts all to execute in one hour. Each iteration of your loop takes only a fraction of a millisecond or maybe a tad bit more than that. To enqueue them properly, you could do 3600000 * count instead of 3600000 each time.

    This is a terrible way to do it though. You should use AlarmManager for stuff like this.

提交回复
热议问题