Java Code Examples for android.os.Message#sendToTarget()
The following examples show how to use
android.os.Message#sendToTarget() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MLAlertController.java From NewXmPluginSDK with Apache License 2.0 | 6 votes |
public void onClick(View v) { Message m = null; if (v == mButtonPositive && mButtonPositiveMessage != null) { m = Message.obtain(mButtonPositiveMessage); } else if (v == mButtonNegative && mButtonNegativeMessage != null) { m = Message.obtain(mButtonNegativeMessage); } else if (v == mButtonNeutral && mButtonNeutralMessage != null) { m = Message.obtain(mButtonNeutralMessage); } if (m != null) { m.sendToTarget(); } if (mAutoDismiss) { // Post a message so we dismiss after the above handlers are // executed mHandler.obtainMessage(ButtonHandler.MSG_DISMISS_DIALOG, mDialogInterface) .sendToTarget(); } }
Example 2
Source File: Bundle.java From Small with Apache License 2.0 | 6 votes |
protected static void postUI(final Runnable action) { if (sHandler == null) { action.run(); return; } beginUI(); Message msg = Message.obtain(sHandler, new Runnable() { @Override public void run() { action.run(); commitUI(); } }); msg.sendToTarget(); }
Example 3
Source File: BarCodeScannerHandler.java From zxingfragmentlib with Apache License 2.0 | 6 votes |
public void quitSynchronously() { state = State.DONE; cameraManager.stopPreview(); Message quit = Message.obtain(decodeThread.getHandler(), QUIT); quit.sendToTarget(); try { // Wait at most half a second; should be enough time, and onPause() will timeout quickly decodeThread.join(500L); } catch (InterruptedException e) { // continue } // Be absolutely sure we don't send any queued up messages removeMessages(DECODE_SUCCEDED); removeMessages(DECODE_FAILED); }
Example 4
Source File: LocalNetActivity.java From AndroidDemo with MIT License | 6 votes |
@Override public JSONObject handleRequest(JSONObject json) throws JSONException { Message msg = handler.obtainMessage(); msg.obj = json.toString(); msg.what = 0; msg.sendToTarget(); String cmd = json.optString("cmd"); switch (cmd) { case Constant.CONNECT: { JSONArray content = new JSONArray(); JSONObject jo = new JSONObject(); jo.put("server_ip", "192.168.100.100"); jo.put("server_port", "5001"); jo.put("device_type", "gateway"); content.put(jo); json.put("content", content); break; } default: break; } return json; }
Example 5
Source File: CaptureActivityHandler.java From imsdk-android with MIT License | 6 votes |
public void quitSynchronously() { state = State.DONE; cameraManager.stopPreview(); Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit); quit.sendToTarget(); try { // Wait at most half a second; should be enough time, and onPause() // will timeout quickly decodeThread.join(500L); } catch (InterruptedException e) { // continue } // Be absolutely sure we don't send any queued up messages removeMessages(R.id.decode_succeeded); removeMessages(R.id.decode_failed); }
Example 6
Source File: UploadPresenter.java From smart-farmer-android with Apache License 2.0 | 5 votes |
@Override public void doOnPreUpload(@NonNull final T t) { if (Thread.currentThread() == myThread) { mView.beforeUpload(t); } else { Message message = Message.obtain(handler); message.what = MES_PRE_UPLOAD; message.obj = t; message.sendToTarget(); } }
Example 7
Source File: MediaAsync.java From MediaChooser with Apache License 2.0 | 5 votes |
private Result postResult(Result result) { @SuppressWarnings("unchecked") Message message = (sHandler).obtainMessage(MESSAGE_POST_RESULT, new AsyncTaskResult<Result>(this, result)); message.sendToTarget(); return result; }
Example 8
Source File: WXBridgeManager.java From weex with Apache License 2.0 | 5 votes |
private void post(Runnable r, Object token) { if (mJSHandler == null) { return; } Message m = Message.obtain(mJSHandler, r); m.obj = token; m.sendToTarget(); }
Example 9
Source File: PreviewCallback.java From Mobike with Apache License 2.0 | 5 votes |
public void onPreviewFrame(byte[] data, Camera camera) { Point cameraResolution = configManager.getCameraResolution(); if (!useOneShotPreviewCallback) { camera.setPreviewCallback(null); } if (previewHandler != null) { Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x, cameraResolution.y, data); message.sendToTarget(); previewHandler = null; } else { Log.d(TAG, "Got preview callback, but no handler for it"); } }
Example 10
Source File: SignalingClient.java From restcomm-android-sdk with GNU Affero General Public License v3.0 | 5 votes |
/** * Send text message to peer * @param parameters * @return */ public String sendMessage(HashMap<String, Object> parameters) { String jobId = generateId(); SignalingMessage signalingMessage = new SignalingMessage(jobId, SignalingMessage.MessageType.MESSAGE_REQUEST); signalingMessage.parameters = parameters; Message message = signalingHandler.obtainMessage(1, signalingMessage); message.sendToTarget(); //messages.put(jobId, rcMessage); return jobId; }
Example 11
Source File: ACSUtilityService.java From ESeal with Apache License 2.0 | 5 votes |
@Override public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { // broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic); byte[] value = characteristic.getValue(); Message msg = null; Log.d(TAG, "onCharacteristicChanged"); if (characteristic.getUuid().equals(CMD_LINE_UUID)) { //命令线 // Log.d(tag, "data from CMD_LINE_UUID"); if (value[0] == 0x05) { Log.d(TAG, "heart beat package write back "); /* * if (userCallback != null) { * userCallback.heartbeatDebug(); } */ msg = mCurrentEventHandler.obtainMessage(EVENT_HEART_BEAT_DEBUG); byte[] handshake = {0x05}; characteristic.setValue(handshake); mBluetoothGatt.writeCharacteristic(characteristic); } } else if (characteristic.getUuid().equals(DATA_LINE_UUID)) { //数据线 Log.d(TAG, "data line : length = " + value.length); // printHexString(value); // checkPackageToSend(characteristic.getValue()); msg = mCurrentEventHandler.obtainMessage(EVENT_DATA_AVAILABLE); Bundle bundle = new Bundle(); bundle.putByteArray(EXTRA_DATA, characteristic.getValue()); msg.setData(bundle); // userCallback.didPackageReceived(currentPort, // characteristic.getValue()); } msg.sendToTarget(); }
Example 12
Source File: SignalingClient.java From restcomm-android-sdk with GNU Affero General Public License v3.0 | 5 votes |
/** * Release the signaling facilities * @return */ public String close() { String jobId = generateId(); SignalingMessage signalingMessage = new SignalingMessage(jobId, SignalingMessage.MessageType.CLOSE_REQUEST); //signalingMessage.setParameters(parameters); Message message = signalingHandler.obtainMessage(1, signalingMessage); message.sendToTarget(); /* closePending = true; new Handler(getLooper()).postDelayed( new Runnable() { @Override public void run() { if (closePending) { RCLogger.w(TAG, "close() timeout: signaling thread didn't return after: " + CLOSE_TIMEOUT + "ms. Stopping signaling thread"); signalingHandlerThread.quit(); } } } , CLOSE_TIMEOUT); */ return jobId; }
Example 13
Source File: Filter.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * <p>Handles filtering requests by calling * {@link Filter#performFiltering} and then sending a message * with the results to the results handler.</p> * * @param msg the filtering request */ public void handleMessage(Message msg) { int what = msg.what; Message message; switch (what) { case FILTER_TOKEN: RequestArguments args = (RequestArguments) msg.obj; try { args.results = performFiltering(args.constraint); } catch (Exception e) { args.results = new FilterResults(); Log.w(LOG_TAG, "An exception occured during performFiltering()!", e); } finally { message = mResultHandler.obtainMessage(what); message.obj = args; message.sendToTarget(); } synchronized (mLock) { if (mThreadHandler != null) { Message finishMessage = mThreadHandler.obtainMessage(FINISH_TOKEN); mThreadHandler.sendMessageDelayed(finishMessage, 3000); } } break; case FINISH_TOKEN: synchronized (mLock) { if (mThreadHandler != null) { mThreadHandler.getLooper().quit(); mThreadHandler = null; } } break; } }
Example 14
Source File: SwipeableCell.java From iscanner_android with MIT License | 5 votes |
private void showRight(View view) { Message msg = new MoveHandler().obtainMessage(); msg.obj = view; msg.arg1 = view.getScrollX(); msg.arg2 = mRightViewWidth; msg.sendToTarget(); mIsShown = true; }
Example 15
Source File: LiveFrameProcessingThread.java From CamView with Apache License 2.0 | 5 votes |
public void shutdown() { final Message message = Message.obtain(getDecoderHandler(), R.id.camview_core_msg_livedataprocess_quit); if (message != null) { message.sendToTarget(); } }
Example 16
Source File: CaptureActivityHandler.java From KSYMediaPlayer_Android with Apache License 2.0 | 5 votes |
public void quitSynchronously() { state = State.DONE; CameraManager.get().stopPreview(); Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit); quit.sendToTarget(); try { decodeThread.join(); } catch (InterruptedException e) { // continue } // Be absolutely sure we don't send any queued up messages removeMessages(R.id.decode_succeeded); removeMessages(R.id.decode_failed); }
Example 17
Source File: OpenVPNStatusService.java From bitmask_android with GNU General Public License v3.0 | 4 votes |
@Override public void updateByteCount(long in, long out, long diffIn, long diffOut) { Message msg = mHandler.obtainMessage(SEND_NEW_BYTECOUNT, Pair.create(in, out)); msg.sendToTarget(); }
Example 18
Source File: CallbackHandler.java From sketch with Apache License 2.0 | 4 votes |
void postInitCompleted(ImageRegionDecoder decoder, String imageUri, int initKey, KeyCounter keyCounter) { Message message = obtainMessage(CallbackHandler.WHAT_INIT_COMPLETED); message.arg1 = initKey; message.obj = new InitResult(decoder, imageUri, keyCounter); message.sendToTarget(); }
Example 19
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 4 votes |
/** * exposes setDisplayShowHomeEnabled * @param boolean */ @Kroll.method @Kroll.setProperty public void setDisplayShowHomeEnabled(boolean showHome){ Message message = getMainHandler().obtainMessage(MSG_DISPLAY_HOME, showHome); message.sendToTarget(); }
Example 20
Source File: Galgo.java From MVPAndroidBootstrap with Apache License 2.0 | 2 votes |
/** * Logs a String message to the screen. This String will be overlayed on top of the * UI elements currently displayed on screen. As a side effect, this message will * also be logged to the standard output via {@link android.util.Log}. * * @param message String to be displayed */ public static void log(String message) { Log.i(TAG, message); Message msg = UI_HANDLER.obtainMessage(0, message); msg.sendToTarget(); }