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

This code example shows how to use the following methods: obtainMessage, sendMessage
     */ 
    @Override 
    public int onStartCommand(Intent intent, int flags, int startId) {
        if (DBG) Slog.d(TAG, "onStartCommand");
 
        Message msg = mHandler.obtainMessage();
        msg.what = CMD_ASYNC_SERVICE_ON_START_INTENT;
        msg.arg1 = flags;
        msg.arg2 = startId;
        msg.obj = intent;
        mHandler.sendMessage(msg);
 
        return mAsyncServiceInfo.mRestartFlags;
    } 
 
    /** 
     * Called when service is destroyed. After returning the 
     * service is dead and no more processing should be expected 
     * to occur. 
     */ 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: obtainMessage, removeMessages, sendMessage
 
        absListView.invalidate();
    } 
 
    private void postUpdateItems() { 
        Message msg = mHandler.obtainMessage(MESSAGE_UPDATE_ITEMS,
                                             ItemManager.this);
 
        mHandler.removeMessages(MESSAGE_UPDATE_ITEMS);
        mPendingItemsUpdate = true;
 
        mHandler.sendMessage(msg);
    } 
 
    void setItemManaged(ItemManaged itemManaged) {
        mManaged = itemManaged;
 
        if (mManaged != null) {
            AbsListView absListView = mManaged.getAbsListView();
 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: obtainMessage, sendMessage
		@Override 
		public void onReceive(Context context, Intent intent) {
			int intExtra = intent.getIntExtra("tab", 0);
			Log.i(TabChangeReceiver.class.getSimpleName(), "Recieved broadcast with extra=[" + intExtra + "]");
			 
			mHandler.sendMessage(mHandler.obtainMessage(SWITCH_TAB, intExtra, 0));
		} 
	} 
	 
	private TabHost host;
	public static final int SWITCH_TAB = 2545;
	protected static TabChangeReceiver receiver;
	 
} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: obtainMessage, removeMessages, sendMessage, sendMessageDelayed
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: obtainMessage, sendMessage
            executeMessage(msg);
            msg.recycle();
            return; 
        } 
         
        mH.sendMessage(msg);
    } 
     
    void executeMessage(Message msg) {
        switch (msg.what) {
            case DO_GET_TEXT_AFTER_CURSOR: {
                SomeArgs args = (SomeArgs)msg.obj;
                try { 
                    InputConnection ic = mInputConnection.get();
                    if (ic == null || !isActive()) {
                        Log.w(TAG, "getTextAfterCursor on inactive InputConnection");
                        args.callback.setTextAfterCursor(null, args.seq);
                        return; 
                    } 
                    args.callback.setTextAfterCursor(ic.getTextAfterCursor(

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: obtainMessage, sendMessage
    public class TabChangeReceiver extends android.content.BroadcastReceiver{
		@Override 
		public void onReceive(Context context, Intent intent) {
			int intExtra = intent.getIntExtra("tab", 0);
			Log.i(TabChangeReceiver.class.getSimpleName(), "Recieved broadcast with extra=[" + intExtra + "]");
			mHandler.sendMessage(mHandler.obtainMessage(SWITCH_TAB, intExtra, 0));
		} 
	} 
 
	private OnClickListener goToTab1() {
		return new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent("com.novoda.TAB");
				intent.putExtra("tab", 0);
				sendBroadcast(intent);
			} 
		}; 
	}	 
	 
	private OnClickListener goToTab2() {
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: obtainMessage, removeMessages, sendMessage
	public static synchronized void sendBTCMotorMessage(int delay, int motor, int speed, int angle) {
		Bundle myBundle = new Bundle();
		myBundle.putInt("motor", motor);
		myBundle.putInt("speed", speed);
		myBundle.putInt("angle", angle);
		Message myMessage = btcHandler.obtainMessage();
		myMessage.setData(myBundle);
		myMessage.what = motor;
 
		if (delay == 0) {
 
			btcHandler.removeMessages(motor);
			btcHandler.sendMessage(myMessage);
 
		} else { 
			//btcHandler.removeMessages(motor); 
			btcHandler.sendMessageDelayed(myMessage, delay);
 
		} 
	} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: obtainMessage, removeMessages, sendMessage
	public static synchronized void sendBTCMotorMessage(int delay, int motor, int speed, int angle) {
		Bundle myBundle = new Bundle();
		myBundle.putInt("motor", motor);
		myBundle.putInt("speed", speed);
		myBundle.putInt("angle", angle);
		Message myMessage = btcHandler.obtainMessage();
		myMessage.setData(myBundle);
		myMessage.what = motor;
 
		if (delay == 0) {
 
			btcHandler.removeMessages(motor);
			btcHandler.sendMessage(myMessage);
 
		} else { 
			//btcHandler.removeMessages(motor); 
			btcHandler.sendMessageDelayed(myMessage, delay);
 
		} 
	} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: obtainMessage, sendMessage
     */ 
    @Override 
    public int onStartCommand(Intent intent, int flags, int startId) {
        if (DBG) Slog.d(TAG, "onStartCommand");
 
        Message msg = mHandler.obtainMessage();
        msg.what = CMD_ASYNC_SERVICE_ON_START_INTENT;
        msg.arg1 = flags;
        msg.arg2 = startId;
        msg.obj = intent;
        mHandler.sendMessage(msg);
 
        return mAsyncServiceInfo.mRestartFlags;
    } 
 
    /** 
     * Called when service is destroyed. After returning the 
     * service is dead and no more processing should be expected 
     * to occur. 
     */ 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: obtainMessage, sendMessage
	public boolean handleMessage(Message message)
	{ 
		switch (message.what) {
		case MSG_RUN_QUERY: {
			Cursor cursor = runQuery(mContext.getContentResolver());
			mUiHandler.sendMessage(mUiHandler.obtainMessage(MSG_UPDATE_CURSOR, cursor));
			break; 
		} 
		case MSG_UPDATE_CURSOR:
			changeCursor((Cursor)message.obj);
			break; 
		default: 
			return false; 
		} 
 
		return true; 
	} 
 
	/** 
	 * Query the playlist songs. 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Handler sendMessage Questions & Answers:

sendMessage Method Overview
Pushes a message onto the end of the message queue after all pending messages before the current time.
See Code Examples for other Android Handler Methods: