且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android的:如何设置的方法时间上的差距,当睡眠或等待不工作

更新时间:2022-03-19 04:10:28

如果您要延迟一些code,你应该将它张贴在延迟时间的处理程序。
这样的处理将等待指定的时间,然后执行给定的可运行。

If you want to delay some code, you should post it in a handler with a delay time. This way the handler will wait the given time and then execute the given runnable.

    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            cpuPlay();
        }
    }, TIME_TO_WAIT_IN_MS);