Android interval timing loop executes the function N times and then ends the function realization analysis

This timed loop execution task of Android is very common in principle, but many people write it so that I can't understand it, or it is not easy to use. Here I give the actual code for your reference. What we should pay attention to is that postDelayed is not a function of setting a cyclic task. It is only a timing function. Unlike the timer TimerTask, the TimerTask is cyclically executed.
Here just use the delay in the thread to execute again, constructing a loop effect.

private void testGpio(){
   
    
    
        Toast.makeText(context,"开始执行",Toast.LENGTH_LONG).show

Guess you like

Origin blog.csdn.net/poolooloo/article/details/108486717