Handler sendMessageDelayed - 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 sendMessageDelayed method.

This code example shows how to use the following methods:obtainMessage, removeMessages, sendMessage, sendMessageDelayed
 
        String url = ( String ) msg.obj;
        if ( msg.what == GET_REMOTE_IMAGE )
        { 
            // while decoding the new image, show the default album art 
            Message numsg = mParentHandler
                    .obtainMessage( REMOTE_IMAGE_DECODED, null );
            mParentHandler.removeMessages( REMOTE_IMAGE_DECODED );
            mParentHandler.sendMessageDelayed( numsg, 300 );
            Bitmap bm = getArtwork( url );
            if ( bm != null )
            { 
                numsg = mParentHandler.obtainMessage( REMOTE_IMAGE_DECODED, bm );
                mParentHandler.removeMessages( REMOTE_IMAGE_DECODED );
                mParentHandler.sendMessage( numsg );
            } 
        } 
    } 
     
    private Bitmap getArtwork( String urlstr )
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:obtainMessage, removeMessages, sendMessageDelayed
    /** 
     * Start up the pulse to fade the screen, clearing any existing pulse to 
     * ensure that we don't have multiple pulses running at a time. 
     */ 
    void startFading() { 
        mHandler.removeMessages(MSG_FADE);
        scheduleFade(); 
    } 
 
    /** 
     * Stop the pulse to fade the screen. 
     */ 
    void stopFading() { 
        mHandler.removeMessages(MSG_FADE);
    } 
 
    /** 
     * Schedule a fade message for later. 
     */ 
    void scheduleFade() { 

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:obtainMessage, sendMessageDelayed
    } 
 
    public void onStart() { 
        super.onStart(); 
        setEnabled(false); 
        mHandler.sendMessageDelayed(mHandler.obtainMessage(0), 1000);
    } 
 
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (mConsuming) {
            //Slog.i(TAG, "Consuming: " + event); 
            return true; 
        } 
        //Slog.i(TAG, "Dispatching: " + event); 
        return super.dispatchKeyEvent(event);
    } 
 
    private void setEnabled(boolean enabled) {
        Button b = (Button)findViewById(R.id.button1);
        if (b != null) {
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:obtainMessage, sendMessageDelayed
    this.autoFocusMessage = autoFocusMessage;
  } 
 
  public void onAutoFocus(boolean success, Camera camera) {
    if (autoFocusHandler != null) {
      Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success);
      // Simulate continuous autofocus by sending a focus request every 
      // AUTOFOCUS_INTERVAL_MS milliseconds. 
      //Log.d(TAG, "Got auto-focus callback; requesting another"); 
      autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS);
      autoFocusHandler = null;
    } else { 
      Log.d(TAG, "Got auto-focus callback, but no handler for it");
    } 
  } 
 
} 
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:obtainMessage, sendMessageDelayed
        Log.v(LOGTAG, "Navigating to URL: " + url);
        webView.loadUrl(url);
 
        if(timeout != 0) {
            //set a timer with specified timeout (in ms) 
            handler.sendMessageDelayed(handler.obtainMessage(MSG_TIMEOUT),
                    timeout);
        } 
    } 
 
    @Override 
    protected void onDestroy() { 
        super.onDestroy(); 
        Log.v(LOGTAG, "onDestroy, inst=" + Integer.toHexString(hashCode()));
        webView.clearCache(true);
        webView.destroy();
    } 
 
    private boolean isPageDone() { 
        synchronized (pageDoneLock) {
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:obtainMessage, removeMessages, sendMessageDelayed
	private void handleIntent(Intent intent) {
		mProcessor.execute(intent);
	} 
	 
	private void sendStopMessage(Intent request) {
		mHandler.removeMessages(MSG_STOP);
		int startId = request.getIntExtra(EXTRA_START_ID, 0);
		mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_STOP, startId, 0), getIdleStopTime());
	} 
 
	protected long getIdleStopTime() { 
		return 10000; // 10 seconds 
	} 
 
	private void stop(int startId) {
		if(shouldStopOnAllOperationsComplete() && stopSelfResult(startId)) {
			if(mEnableLogging) {
				Log.d(mLogTag, String.format("[Stopping] startId:%s", startId));
			} 
			 
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:hasMessages, obtainMessage, sendMessageDelayed
            // interface to clear the audio pipeline. 
            delay = 1000;
        } else { 
            // Insert the same delay for headset connection so that the connection event is not 
            // broadcast before the disconnection event in case of fast removal/insertion 
            if (mHandler.hasMessages(0)) {
                delay = 1000;
            } 
        } 
        mWakeLock.acquire();
        mHandler.sendMessageDelayed(mHandler.obtainMessage(0,
                                                           mHeadsetState,
                                                           mPrevHeadsetState,
                                                           mHeadsetName),
                                    delay);
    } 
 
    private synchronized final void sendIntents(int headsetState, int prevHeadsetState, String headsetName) {
        int allHeadsets = SUPPORTED_HEADSETS;
        for (int curHeadset = 1; allHeadsets != 0; curHeadset <<= 1) {
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:obtainMessage, removeMessages, sendMessageDelayed
        return null; 
    } 
 
    public void onRequestTexture(int id) {
        if (DBG) Log.v(TAG, "onRequestTexture(" + id + ")" );
        mAsyncHandler.removeMessages(REQUEST_TEXTURE_N + id);
        Message message = mAsyncHandler.obtainMessage(REQUEST_TEXTURE_N + id, id, 0);
        mAsyncHandler.sendMessageDelayed(message, HOLDOFF_DELAY);
    } 
 
    public void onInvalidateTexture(final int id) {
        if (DBG) Log.v(TAG, "onInvalidateTexture(" + id + ")");
        mAsyncHandler.removeMessages(REQUEST_TEXTURE_N + id);
    } 
 
    public void onRequestGeometry(int id) {
        if (DBG) Log.v(TAG, "onRequestGeometry(" + id + ")");
        mAsyncHandler.removeMessages(REQUEST_GEOMETRY_N + id);
        mAsyncHandler.sendMessage(mAsyncHandler.obtainMessage(REQUEST_GEOMETRY_N + id, id, 0));
    } 
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:obtainMessage, removeMessages, sendEmptyMessage, sendMessageDelayed
			mShowing = true;
			if (mShownListener != null)
				mShownListener.onShown();
		} 
		updatePausePlay(); 
		mHandler.sendEmptyMessage(SHOW_PROGRESS);
 
		if (timeout != 0) {
			mHandler.removeMessages(FADE_OUT);
			mHandler.sendMessageDelayed(mHandler.obtainMessage(FADE_OUT),
					timeout);
		} 
	} 
 
	public boolean isShowing() { 
		return mShowing;
	} 
 
	public void hide() { 
		if (mAnchor == null)
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:sendMessageDelayed, obtain
     */ 
    private void updateRunning() { 
        if (timerStarted != timerRunning) {
            if (timerStarted) {
                dispatchTimerUpdate(SystemClock.elapsedRealtime());
                timerHandler.sendMessageDelayed(Message.obtain(timerHandler, TICK_WHAT), 1000);
            } else { 
                timerHandler.removeMessages(TICK_WHAT);
            } 
            timerRunning = timerStarted;
        } 
    } 
 
    private Handler timerHandler = new Handler() {
        public void handleMessage(Message m) { 
            if (timerRunning) { 
                dispatchTimerUpdate(SystemClock.elapsedRealtime()); 
                sendMessageDelayed(Message.obtain(this, TICK_WHAT), 1000); 
            } 
        } 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Handler sendMessageDelayed Questions & Answers:

sendMessageDelayed Method Overview
Enqueue a message into the message queue after all pending messages before (current time + delayMillis).
See Code Examples for other Android Handler Methods: