Code example for Handler

Methods: obtainMessageremoveMessagessendMessageDelayed

0
        postCheckMemoryMsg(true, DEFAULT_CHECK_INTERVAL);
    } 
     
    private void postCheckMemoryMsg(boolean clearCache, long delay) {
        // Remove queued messages 
        mHandler.removeMessages(DEVICE_MEMORY_WHAT);
        mHandler.sendMessageDelayed(mHandler.obtainMessage(DEVICE_MEMORY_WHAT,
                clearCache ?_TRUE : _FALSE, 0),
                delay);
    } 
     
    /* 
     * just query settings to retrieve the memory threshold.  
     * Preferred this over using a ContentObserver since Settings.Gservices caches the value 
     * any way 
     */ 
    private long getMemThreshold() { 
        int value = Settings.Gservices.getInt(
                              mContentResolver, 
                              Settings.Gservices.SYS_STORAGE_THRESHOLD_PERCENTAGE,  
                              DEFAULT_THRESHOLD_PERCENTAGE);