Code example for Handler

Methods: hasMessagessendEmptyMessage

0
        b.setText(label);
    } 
 
 
    public void insertItems(View v) {
        if (mInsertHandler.hasMessages(0)) {
            mInsertHandler.removeMessages(0);
            setInsertButtonText(); 
        } else { 
            mInsertHandler.sendEmptyMessage(0);
        } 
    } 
 
    Handler mInsertHandler = new Handler() {
        @Override 
        public void handleMessage(Message msg) { 
 
            if (mNumToInsert-- > 0) { 
                addAlbum(); 
                runOnUiThread(mDisplayUpdater);