zoukankan      html  css  js  c++  java
  • android studio定时器

    1.超时   

    CountDownTimer第一个参数超时时间,第二个参数多久执行一次onTick(), 到达设定的超时时间执行onFinsh(),cancel取消超时计数,start重新开始(从零开始)。
     private CountDownTimer afterRunTimer=new CountDownTimer(2000,2000) {
            @Override
            public void onTick(long l) {
    
    
                LogUtil.d("TAG", "onTick: afterRunTimer");
            }
    
            @Override
            public void onFinish() {
    
    
                afterRunTimer.cancel();
    
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
    
                        LogUtil.d("TAG", "onFinish: afterRunTimer  readSN");
                        readSN();
    
    
    
                    }
                });
    
    
            }
        };

     2.  

    handler.postDelayed(myRunnable,1000);
     private Handler handler=new Handler();
    
        private Runnable myRunnable=new Runnable() {
            @Override
            public void run() {
    
    
                Log.d("TAG","myRunnable");
                //间隔时间循环执行
                //handler.postDelayed(myRunnable,1000);
            }
        };
  • 相关阅读:
    Kakuro Extension HDU
    CodeForces
    HDU
    2019牛客暑期多校训练营(第二场)F.Partition problem
    UVA
    团队冲刺6
    团队冲刺4
    团队冲刺3
    团队冲刺2
    团队冲刺1
  • 原文地址:https://www.cnblogs.com/ike_li/p/9639615.html
Copyright © 2011-2022 走看看