当前位置: 首页>>代码示例>>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;未经允许,请勿转载。