Handler postDelayed delayed longer as configured

后端 未结 2 1793
无人共我
无人共我 2021-01-16 15:01

I try to develop a simple timer beeper, that peep hourly. For the timing I use a Service and handler, here the example:

    void onStart(...){
        handle         


        
相关标签:
2条回答
  • 2021-01-16 15:34

    You'll probably have better luck using the AlarmManager for such a long delay. Handler is best for ticks and timeouts while your app is in the foreground.

    http://developer.android.com/reference/android/app/AlarmManager.html

    0 讨论(0)
  • 2021-01-16 15:45

    Android is not a real-time operating system. All postDelayed() guarantees is that it will be at least the number of milliseconds specified. Beyond that will be dependent primarily on what the main application thread is doing (if you are tying it up, it cannot process the Runnable), and secondarily on what else is going on the device (services run with background priority and therefore get less CPU time than does the foreground).

    0 讨论(0)
提交回复
热议问题