Code example for Handler

Methods: removeMessagessendEmptyMessageDelayed

0
                 * (!isReceivedDirectMessagesRefreshing()) { 
                 * getReceivedDirectMessages(activated_ids, null, true); } } 
                 */ 
                // Log.d("Notifications", "Tick [" + mCount + "]"); 
                mCount += 1; 
                mHandler.removeMessages(ACTION_AUTO_REFRESH); 
 
                sendMessageToUI(mCount); 
                // showNotification(); 
 
                // Toast.makeText(mContext, "Toast!!!!", 
                // Constant.DEFAULT_TOAST_DISPLAY_TIME).show(); 
 
                // final long update_interval = 
                // parseInt(mPreferences.getString(PREFERENCE_KEY_REFRESH_INTERVAL, 
                // "30")) * 60 * 1000; 
                final long update_interval = 20 * 1000; 
                // if (update_interval <= 0 || 
                // !mPreferences.getBoolean(PREFERENCE_KEY_AUTO_REFRESH, false)) 
                // { 
                // break; 
                // } 
                mHandler.sendEmptyMessageDelayed(ACTION_AUTO_REFRESH, 
                        update_interval); 
                break; 
            } 
            } 
        }