Android timer handler 實現定時

mHandler =  new Handler(){
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                switch (msg.what){
                    case 0:
                        Logger.i("在hanler中的信息");
                        break;
                    case 1:
                        break;
                }
            }
        };
        timer = new Timer();
        timer.schedule(new TimerTask(){
            @Override
            public void run() {
                Logger.i("在Timer中的線程");
                mHandler.sendEmptyMessage(0);
            }
        }, 0, 2000);
相關文章
相關標籤/搜索