Code example for Handler

Methods: obtainMessageremoveMessagessendMessageDelayed

0
    /** 
     * Start up the pulse to fade the screen, clearing any existing pulse to 
     * ensure that we don't have multiple pulses running at a time. 
     */ 
    void startFading() { 
        mHandler.removeMessages(MSG_FADE);
        scheduleFade(); 
    } 
 
    /** 
     * Stop the pulse to fade the screen. 
     */ 
    void stopFading() { 
        mHandler.removeMessages(MSG_FADE);
    } 
 
    /** 
     * Schedule a fade message for later. 
     */ 
    void scheduleFade() { 
        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_FADE), FADE_DELAY);
    } 
 
    private Handler mHandler = new Handler() {
        @Override 
        public void handleMessage(Message msg) {