Java Code Examples for android.os.Handler.postAtTime()

The following are Jave code examples for showing how to use postAtTime() of the android.os.Handler class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: AndroidTvDemo   File: DateView.java   Source Code and License Vote up 6 votes
@Override
protected void onAttachedToWindow()
{
    mTickerStopped = false;
    super.onAttachedToWindow();
    mHandler = new Handler();
    
    /**
     * requests a tick on the next hard-second boundary
     */
    mTicker = new Runnable()
    {
        @Override
        public void run()
        {
            if (mTickerStopped)
                return;
            mCalendar.setTimeInMillis(System.currentTimeMillis());
            setText(DateFormat.format(mFormat, mCalendar));
            invalidate();
            long now = SystemClock.uptimeMillis();
            long next = now + (1000 - now % 1000);
            mHandler.postAtTime(mTicker, next);
        }
    };
    mTicker.run();
}
 
Example 2
Project: LaunchEnr   File: LauncherAppWidgetHostView.java   Source Code and License Vote up 5 votes
private void scheduleNextAdvance() {
    if (!mIsAutoAdvanceRegistered) {
        return;
    }
    long now = SystemClock.uptimeMillis();
    long advanceTime = now + (ADVANCE_INTERVAL - (now % ADVANCE_INTERVAL)) +
            ADVANCE_STAGGER * sAutoAdvanceWidgetIds.indexOfKey(getAppWidgetId());
    Handler handler = getHandler();
    if (handler != null) {
        handler.postAtTime(mAutoAdvanceRunnable, advanceTime);
    }
}
 
Example 3
Project: TQueue   File: TWorker.java   Source Code and License Vote up 5 votes
protected void queueing(Handler handler){
	if (handler != null) {
		if (type == NORMAL) {
			handler.post(this);
		} else if (type == AT_TIME) {
			handler.postAtTime(this, time);
		}  else if (type == DELAY) {
			handler.postDelayed(this, time);
		} else {}
	}
}
 
Example 4
Project: AndroidTvDemo   File: TimeAPMView.java   Source Code and License Vote up 5 votes
@Override
protected void onAttachedToWindow()
{
    mTickerStopped = false;
    super.onAttachedToWindow();
    mHandler = new Handler();
    
    /**
     * requests a tick on the next hard-second boundary
     */
    mTicker = new Runnable()
    {
        @Override
        public void run()
        {
            if (mTickerStopped)
                return;
            mCalendar.setTimeInMillis(System.currentTimeMillis());
            setText(DateFormat.format(mFormat, mCalendar));
            invalidate();
            long now = SystemClock.uptimeMillis();
            long next = now + (1000 - now % 1000);
            mHandler.postAtTime(mTicker, next);
        }
    };
    mTicker.run();
}
 
Example 5
Project: AndroidTvDemo   File: TimeView.java   Source Code and License Vote up 5 votes
@Override
protected void onAttachedToWindow()
{
    mTickerStopped = false;
    super.onAttachedToWindow();
    mHandler = new Handler();
    
    /**
     * requests a tick on the next hard-second boundary
     */
    mTicker = new Runnable()
    {
        @Override
        public void run()
        {
            if (mTickerStopped)
                return;
            mCalendar.setTimeInMillis(System.currentTimeMillis());
            setText(DateFormat.format(mFormat, mCalendar));
            invalidate();
            long now = SystemClock.uptimeMillis();
            long next = now + (1000 - now % 1000);
            mHandler.postAtTime(mTicker, next);
        }
    };
    mTicker.run();
}
 
Example 6
Project: GravityBox   File: StatusbarClock.java   Source Code and License Vote up 5 votes
private void updateSecondsHandler() {
    if (mClock == null) return;

    if (mShowSeconds && mClock.getDisplay() != null) {
        mSecondsHandler = new Handler();
        if (mClock.getDisplay().getState() == Display.STATE_ON && !mClockHidden) {
            mSecondsHandler.postAtTime(mSecondTick,
                    SystemClock.uptimeMillis() / 1000 * 1000 + 1000);
        }
    } else if (mSecondsHandler != null) {
        mSecondsHandler.removeCallbacks(mSecondTick);
        mSecondsHandler = null;
        updateClock();
    }
}