相关疑难解决方法(0)

这是如何安排java方法在1秒后运行?

在我的方法中,我想调用另一个将在1秒后运行的方法.这就是我所拥有的.

final Timer timer = new Timer();

timer.schedule(new TimerTask() {
    public void run() {
          MyMethod();
          Log.w("General", "This has been called one second later");
        timer.cancel();
    }
}, 1000);
Run Code Online (Sandbox Code Playgroud)

这是应该怎么做的?自从我使用Android以来,还有其他方法吗?可以重复没有任何问题吗?

java android

12
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×1

java ×1