Handler postDelayed - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Handler postDelayed method.

This code example shows how to use the following methods:postDelayed, removeCallbacks
builder.setCheckedItem(clickedPos);
    } 
 
    private void playRingtone(int position, int delayMs) {
        handler.removeCallbacks(this);
        sampleRingtonePos = position;
        handler.postDelayed(this, delayMs);
    } 
 
    @Override 
    public void run() { 
        if (sampleRingtonePos == silentPos) {
            ringtoneManager.stopPreviousRingtone();
            return; 
        } 
        if (defaultRingtone != null && defaultRingtone.isPlaying()) {
            defaultRingtone.stop();
            defaultRingtone = null;
        } 
10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:postDelayed
          this.fail(AccelListener.ERROR_FAILED_TO_START, "No sensors found to register accelerometer listening to.");
          return this.status;
        } 
 
        // Set a timeout callback on the main thread. 
        Handler handler = new Handler(Looper.getMainLooper());
        handler.postDelayed(new Runnable() {
            public void run() { 
                AccelListener.this.timeout();
            } 
        }, 2000); 
 
        return this.status;
    } 
 
    /** 
     * Stop listening to acceleration sensor. 
     */ 
    private void stop() { 
        if (this.status != AccelListener.STOPPED) {
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:postDelayed, removeCallbacks
		} 
	} 
 
	@Override 
	protected void onClick() { 
		mHandler.removeCallbacks(mResetCounterRunnable);
		mClickCount++;
		if (mClickCount >= 7) {
			final Context context = getContext();
			if (context != null) {
				context.startActivity(new Intent(context, NyanActivity.class));
			} 
		} 
		mHandler.postDelayed(mResetCounterRunnable, 3000);
	} 
 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:postDelayed, removeCallbacks
	public void start(Runnable runnable, int delay) {
		this.runnable = runnable;
		this.delay = delay;
 
		if (handler == null)
			handler = new Handler();
 
		started = true;
		run(); 
	} 
 
	public void stop() { 
		started = false;
		handler.removeCallbacks(this);
	} 
 
	public void run() { 
		runnable.run();
		handler.removeCallbacks(this);
		if (started)

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:postDelayed
    public static void inBackground(Runnable r) {
        backgroundExecutor.execute(r);
    } 
     
    public static void delayed(Runnable r, long delayMillis) {
        Handler h = new Handler();
        h.postDelayed(r, delayMillis);
    } 
 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:postDelayed, removeCallbacks
            @Override 
            public boolean onTouch(View v, MotionEvent event) {
                final int action = event.getAction();
                if (action == MotionEvent.ACTION_DOWN) {
                    mContent.setPressed(true);
                    mHandler.removeCallbacks(mSuperLongPress);
                    mCount = 0;
                    mHandler.postDelayed(mSuperLongPress, 2*ViewConfiguration.getLongPressTimeout());
                } else if (action == MotionEvent.ACTION_UP) {
                    if (mContent.isPressed()) {
                        mContent.setPressed(false);
                        mHandler.removeCallbacks(mSuperLongPress);
                        mToast.show();
                    } 
                } 
                return true; 
            } 
        }); 
         
        setContentView(mContent);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:postDelayed
    private static synchronized void startUpdater() { 
        if (handler != null) {
            return; 
        } 
 
        handler = new Handler();
        Runnable runnable = new Runnable() {
            @Override 
            public void run() { 
                updateAll(); 
                handler.postDelayed(this, 1000L);
            } 
        }; 
        handler.postDelayed(runnable, 1000L);
    } 
 
    private static void updateAll() { 
        try { 
            for (SongView view : INSTANCES.keySet()) {
                if (view.isShown()) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:postDelayed, removeCallbacks
This code example shows how to use the following methods:postDelayed, hasCallbacks
    } 
 
    public void init(Context c, int style) {
        mContext = c;
        mStyle = style;
        mHandler = new Handler();
        mObserver = new SettingsObserver(mHandler);
        mObserver.observe();
        setTextSize(ToggleManager.getTextSize(mContext));
        setTextColor(mTextColor);
        scheduleViewUpdate(); 
    } 
 
    protected final void setTextColor(int cl) {
        mTextColor = cl;
    } 
 
    public final int getTextColor() { 
        return mTextColor;
    } 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:postDelayed
		} 
	} 
	 
	public void start() { 
		if(mOnTickCallback != null){
			mHandler.postDelayed(mOnTick, mInterval);
		} 
		mRunning = true;
	} 
	 
	public void stop() { 
		mRunning = false;
		mHandler.removeCallbacks(mOnTick);
	} 
	 
	private Runnable mOnTick = new Runnable() {
		@Override 
		public void run() { 
			if(mOnTickCallback != null){ 
				mOnTickCallback.run(); 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Handler postDelayed Questions & Answers:

Other Handler postDelayed Examples

15:			setContentView(R.layout.activity_splash);
16:	
17:			new Handler().postDelayed(new Runnable() {
18:	
19:				/*

Read More

265:	             playSong(currentSongIndex);
266:	        }
267:	
268:	    }
269:

Read More

postDelayed Method Overview
Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses.
See Code Examples for other Android Handler Methods: