當前位置: 首頁>>代碼示例>>Java>>正文


Java Handler.sendMessage方法代碼示例

本文整理匯總了Java中android.os.Handler.sendMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java Handler.sendMessage方法的具體用法?Java Handler.sendMessage怎麽用?Java Handler.sendMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.Handler的用法示例。


在下文中一共展示了Handler.sendMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerSDK

import android.os.Handler; //導入方法依賴的package包/類
private void registerSDK() {
	// 在嘗試讀取通信錄時以彈窗提示用戶(可選功能)
	SMSSDK.setAskPermisionOnReadContact(true);
	if ("moba6b6c6d6".equalsIgnoreCase(MobSDK.getAppkey())) {
		Toast.makeText(this, R.string.smssdk_dont_use_demo_appkey, Toast.LENGTH_SHORT).show();
	}
	final Handler handler = new Handler(this);
	EventHandler eventHandler = new EventHandler() {
		public void afterEvent(int event, int result, Object data) {
			Message msg = new Message();
			msg.arg1 = event;
			msg.arg2 = result;
			msg.obj = data;
			handler.sendMessage(msg);
		}
	};
	// 注冊回調監聽接口
	SMSSDK.registerEventHandler(eventHandler);
	ready = true;

	// 獲取新好友個數
	showDialog();
	SMSSDK.getNewFriendsCount();
	gettingFriends = true;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:MainActivity.java

示例2: regResponseDataListener

import android.os.Handler; //導入方法依賴的package包/類
/**
 * 注冊監聽響應的DataMap.
 *
 * @param context         c
 * @param dataListenerKey listerId 用於在map中標識監聽器
 * @param handler         用於回傳響應的數據
 * @param sendBothwayId   發送時的BothwayId.
 */
private static void regResponseDataListener(
        final Context context, final long dataListenerKey,
        @NonNull final Handler handler, @NonNull final byte[] sendBothwayId) {
    WTResponseDataListener listener = new WTResponseDataListener() {
        @Override
        public void onResponseDataChanged(byte[] bothwayId, String path, DataMap dataMap) {
            //判斷與發送時的path是否對應,避免同時發送2個請求時響應混亂。
            if (!Arrays.equals(sendBothwayId, bothwayId)) return;

            //雙向通訊響應path格式為:/RE/WTBothway/{nanoTime}/xxx
            Message msg = handler.obtainMessage(HANDLER_RECEIVE_RESPONSE);
            msg.obj = new ResponseDataBean(dataMap, path);
            handler.sendMessage(msg);
            if (dataListenerMap.get(dataListenerKey) != null) {
                WTRegister.removeDataListener(context, dataListenerMap.get(dataListenerKey));
                dataListenerMap.remove(dataListenerKey);
            }
        }
    };
    dataListenerMap.put(dataListenerKey, listener);
    WTRegister.addDataListener(context, listener);
}
 
開發者ID:liangchenhe55,項目名稱:WearTools,代碼行數:31,代碼來源:WTBothway.java

示例3: regResponseMsgListener

import android.os.Handler; //導入方法依賴的package包/類
/**
 * 注冊監聽響應的msg.
 *
 * @param context        c
 * @param msgListenerKey listerId 用於在map中標識監聽器
 * @param handler        用於回傳響應的數據
 * @param sendBothwayId  發送時的BothwayId.
 */
private static void regResponseMsgListener(
        final Context context, final long msgListenerKey,
        @NonNull final Handler handler, @NonNull final byte[] sendBothwayId) {
    WTResponseMsgListener listener = new WTResponseMsgListener() {
        @Override
        public void onResponseMsgReceived(String path, byte[] data, byte[] bothwayId) {
            //判斷與發送時的path是否對應,避免同時發送2個請求時響應混亂。
            if (!Arrays.equals(sendBothwayId, bothwayId)) return;

            //雙向通訊響應path格式為:/RE/WTBothway/{nanoTime}/xxx
            Message msg = handler.obtainMessage(HANDLER_RECEIVE_RESPONSE);
            Bundle bundle = new Bundle();
            bundle.putByteArray("data", data);
            bundle.putString("path", path);
            msg.setData(bundle);
            handler.sendMessage(msg);
            if (msgListenerMap.get(msgListenerKey) != null) {
                WTLog.v(TAG, "Remove response msg listener.");
                WTRegister.removeMessageListener(context, msgListenerMap.get(msgListenerKey));
                msgListenerMap.remove(msgListenerKey);
            }
        }
    };
    WTLog.v(TAG, "Register response msg listener.");
    msgListenerMap.put(msgListenerKey, listener);
    WTRegister.addMessageListener(context, listener);
}
 
開發者ID:liangchenhe55,項目名稱:WearTools,代碼行數:36,代碼來源:WTBothway.java

示例4: deleteUserFace_User

import android.os.Handler; //導入方法依賴的package包/類
public void deleteUserFace_User(String objectId,String faceToken,String faceUrl,Handler myHandler){
	SQLiteDatabase db = databaseHelper.getWritableDatabase();
	ContentValues values = new ContentValues();
	values.put(faceToken, "");
	values.put(faceUrl,"");
	String whereClause = UserMetaData.UserTable.OBJECT_ID + "=?";
	String[] args = {objectId};
	db.update(UserMetaData.UserTable.TABLE_NAME,values,whereClause,args);
	Log.i(TAG, "daleteUserFace_User: success!");
	Message message = Message.obtain();
	message.arg1 = FinalUtil.REMOVE_FACE_SUCCESS;
	myHandler.sendMessage(message);
}
 
開發者ID:tony-Shx,項目名稱:Swface,代碼行數:14,代碼來源:DatabaseAdapter.java

示例5: deleteUser_User

import android.os.Handler; //導入方法依賴的package包/類
public void deleteUser_User(String objectId,Handler myHandler){
	SQLiteDatabase db = databaseHelper.getWritableDatabase();
	String whereClause = UserMetaData.UserTable.OBJECT_ID + "=?";
	String[] args = {objectId};
	db.delete(UserMetaData.UserTable.TABLE_NAME,whereClause,args);
	Log.i(TAG, "deleteUser_User: success!");
	Message message = Message.obtain();
	message.arg1 = FinalUtil.REMOVE_USER_SUCCESS;
	myHandler.sendMessage(message);
}
 
開發者ID:tony-Shx,項目名稱:Swface,代碼行數:11,代碼來源:DatabaseAdapter.java

示例6: batchReport

import android.os.Handler; //導入方法依賴的package包/類
/**
 * commit the data for exposure event in batch
 */
private void batchReport() {
    long time = System.currentTimeMillis();

    Handler handler = ExposureManager.getInstance().getExposureHandler();
    Message message = handler.obtainMessage();
    message.what = ExposureManager.BATCH_COMMIT_EXPOSURE;
    handler.sendMessage(message);

    TrackerLog.v("batch report exposure views " + (System.currentTimeMillis() - time) + "ms");
}
 
開發者ID:alibaba,項目名稱:android_viewtracker,代碼行數:14,代碼來源:TrackerManager.java

示例7: prepareHapticPlayback

import android.os.Handler; //導入方法依賴的package包/類
public void prepareHapticPlayback(int i, int i2) {
    this.b044E044E044E044E044Eю.removeMessages(1);
    Handler handler = this.b044E044E044E044E044Eю;
    Handler handler2 = this.b044E044E044E044E044Eю;
    int i3 = b04290429042904290429Щ;
    switch ((i3 * (b0429ЩЩЩЩ0429 + i3)) % bЩЩ04290429Щ0429()) {
        case 0:
            break;
        default:
            b04290429042904290429Щ = b04290429ЩЩЩ0429();
            bЩЩЩЩЩ0429 = b04290429ЩЩЩ0429();
            break;
    }
    handler.sendMessage(handler2.obtainMessage(1, i, i2));
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:16,代碼來源:HapticPlaybackThread.java

示例8: sendDeviceStatusMessage

import android.os.Handler; //導入方法依賴的package包/類
public void sendDeviceStatusMessage(final Bundle data) {
    Handler handler;
    Message msg;
    for (int i = 0; i < m_lstEH_DevST.size(); i++) {
        handler = m_lstEH_DevST.get(i);
        if (handler != null) {
            msg = handler.obtainMessage();
            if (msg != null) {
                msg.setData(data);
                handler.sendMessage(msg);
            }
        }
    }
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:15,代碼來源:xltDevice.java

示例9: sendSensorDataMessage

import android.os.Handler; //導入方法依賴的package包/類
public void sendSensorDataMessage(final Bundle data) {
    Handler handler;
    Message msg;
    for (int i = 0; i < m_lstEH_SenDT.size(); i++) {
        handler = m_lstEH_SenDT.get(i);
        if (handler != null) {
            msg = handler.obtainMessage();
            if (msg != null) {
                msg.setData(data);
                handler.sendMessage(msg);
            }
        }
    }
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:15,代碼來源:xltDevice.java

示例10: enqueue

import android.os.Handler; //導入方法依賴的package包/類
public boolean enqueue(T data,Callback callback) {

        if(callback == null){
            throw new EventSchedulerRuntimeException("callback must be not null");
        }

        this.mCallback = callback;
        Handler handler = getHandler();
        Message msg = Message.obtain(handler, DISPATCH);
        msg.obj = data;
        return handler.sendMessage(msg);
    }
 
開發者ID:devyok,項目名稱:EventScheduler,代碼行數:13,代碼來源:EventQueueThread.java

示例11: init

import android.os.Handler; //導入方法依賴的package包/類
private void init() {
    decodeBitmapWidth = PicShowUtils.getImageWidth(getContext());
    LogPrinter.i(TAG,"decodeBitmapWidth:" + decodeBitmapWidth
            + "  density:" + getResources().getDisplayMetrics().density);
    myLoadListener = new LoadListener() {
        @Override
        public void startLoad() {
            LogPrinter.i(TAG,"startLoad");
        }

        @Override
        public void finishLoad(Object[] items) {
            LogPrinter.i(TAG,"finishLoad:" + gridAdapter);
            Message msg = mainHandler.obtainMessage();
            msg.what = UPDATE;
            msg.obj = items;
            mainHandler.sendMessage(msg);
        }
    };
    dataLoader = new TimeLinePageDataLoader(getActivity().getApplication(),myLoadListener);

    mainHandler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case UPDATE:
                    if(gridAdapter != null) {
                        gridAdapter.setData((PhotoItem[]) msg.obj);
                    }
                    break;

                default:

                    break;
            }
        }

    };
}
 
開發者ID:YuntaoWei,項目名稱:PictureShow,代碼行數:41,代碼來源:TimeLinePage.java

示例12: init

import android.os.Handler; //導入方法依賴的package包/類
private void init() {
    decodeBitmapWidth = PicShowUtils.getAlbumImageWidth(getContext());
    LogPrinter.i(TAG,"decodeBitmapWidth:" + decodeBitmapWidth);
    myLoadListener = new LoadListener() {
        @Override
        public void startLoad() {

        }

        @Override
        public void finishLoad(Object[] items) {
            Message msg = mainHandler.obtainMessage();
            msg.what = UPDATE;
            msg.obj = items;
            mainHandler.sendMessage(msg);
        }
    };

    dataLoader = new AlbumSetDataLoader(getActivity().getApplication(), myLoadListener);
    mainHandler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case UPDATE:
                    if(gridAdapter != null) {
                        gridAdapter.setData((Album[]) msg.obj);
                    }
                    break;

                default:

                    break;
            }
        }

    };

}
 
開發者ID:YuntaoWei,項目名稱:PictureShow,代碼行數:40,代碼來源:AlbumSetPage.java

示例13: CoolNavigateToTab

import android.os.Handler; //導入方法依賴的package包/類
public void CoolNavigateToTab(int tabId, String tabIdKey, Handler handlerToNotify, boolean clearFragments){
    if (clearFragments){
        this.clearFragments();
    }
    this.notifyDataSetChanged();
    Bundle data = new Bundle();
    Message msg = new Message();
    data.putInt(tabIdKey,tabId);
    msg.setData(data);
    handlerToNotify.sendMessage(msg);
}
 
開發者ID:mikebutrimov,項目名稱:ChemistryEasy,代碼行數:12,代碼來源:MixedPagerAdapter.java

示例14: sendImageMessageToHandler

import android.os.Handler; //導入方法依賴的package包/類
public static void sendImageMessageToHandler(String imageUrl,
		final Handler handler, String id) {
	ZhiChiMessageBase zhichiMessage = new ZhiChiMessageBase();
	ZhiChiReplyAnswer reply = new ZhiChiReplyAnswer();
	reply.setMsg(imageUrl);
	zhichiMessage.setAnswer(reply);
	zhichiMessage.setId(id);

	zhichiMessage.setMysendMessageState(ZhiChiConstant.hander_sendPicIsLoading);
	zhichiMessage.setSenderType(ZhiChiConstant.message_sender_type_customer_sendImage + "");
	Message message = new Message();
	message.what = ZhiChiConstant.message_type_wo_sendImage;
	message.obj = zhichiMessage;
	handler.sendMessage(message);
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:16,代碼來源:ChatUtils.java

示例15: sendTextMessageToHandler

import android.os.Handler; //導入方法依賴的package包/類
/**
 * 文本通知
 * @param id
 * @param msgContent
 * @param handler
 * @param isSendStatus 0 失敗  1成功  2 正在發送
    * @param isUpdate
    */
public void sendTextMessageToHandler(String id, String msgContent,
		Handler handler, int isSendStatus, boolean isUpdate) {
	ZhiChiMessageBase myMessage = new ZhiChiMessageBase();
	myMessage.setId(id);
	ZhiChiReplyAnswer reply = new ZhiChiReplyAnswer();
	if(!TextUtils.isEmpty(msgContent)){
		msgContent = msgContent.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace
				("\n","<br/>").replace("&lt;br/&gt;","<br/>");
		reply.setMsg(msgContent);
	}else{
		reply.setMsg(msgContent);
	}
	reply.setMsgType(ZhiChiConstant.message_type_text + "");
	myMessage.setAnswer(reply);
	myMessage.setSenderType(ZhiChiConstant.message_sender_type_customer + "");
	myMessage.setSendSuccessState(isSendStatus);
	Message handMyMessage = handler.obtainMessage();
	if (!isUpdate) {// 顯示發送成功的狀態
		handMyMessage.what = ZhiChiConstant.hander_my_senderMessage;

	} else {// 發送失敗的狀態
		handMyMessage.what = ZhiChiConstant.hander_my_update_senderMessageStatus;
	}

	handMyMessage.obj = myMessage;
	handler.sendMessage(handMyMessage);
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:36,代碼來源:SobotBaseActivity.java


注:本文中的android.os.Handler.sendMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。