List of usage examples for android.os Message setData
public void setData(Bundle data)
From source file:com.zsxj.pda.ui.client.LoginActivity.java
@Override public void onReponse(Object id, InputStream data) throws IOException { if (null != mUpdateDataId && mUpdateDataId.toString().equals(id.toString())) { try {//from w ww . j av a 2 s . com String rtnData = new String(Util.readDataFromIS(data)); if (null == rtnData || rtnData.equals("")) { sendCheckUpdateRequest(); return; } JSONObject result = new JSONObject(rtnData); // Message return Bundle bundle = new Bundle(); bundle.putInt("update_type", result.optJSONObject("init_response").optInt("update_type")); bundle.putInt("update_method", result.optJSONObject("init_response").optInt("update_method")); bundle.putString("update_url", result.optJSONObject("init_response").optString("update_url")); bundle.putString("update_ver", result.optJSONObject("init_response").optString("update_ver")); bundle.putLong("update_size", result.optJSONObject("init_response").optLong("update_size")); bundle.putString("update_msg", result.optJSONObject("init_response").optString("update_msg")); Message message = new Message(); message.what = HandlerCases.UPDATE_CHECK; message.setData(bundle); handler.sendMessage(message); } catch (Exception e) { } } }
From source file:com.photon.phresco.nativeapp.eshop.activity.PhrescoActivity.java
/** * Call the error dialog handler method to open the normal error dialog box * with OK and Cancel buttons//from w w w. ja v a 2 s. c o m */ public void showErrorDialogWithCancel() { try { PhrescoLogger.info(TAG + " processOnComplete - showErrorDialogHandler :"); Message msg = new Message(); Bundle errorMessageBundle = new Bundle(); errorMessageBundle.putString(errMessage, getString(R.string.http_connect_error_message)); errorMessageBundle.putBoolean(cancelFlag, true); msg.setData(errorMessageBundle); msg.what = ERROR_DIALOG_FLAG; showErrorDialogHandler.sendMessage(msg); } catch (Exception ex) { PhrescoLogger.info(TAG + " - showErrorDialogWithCancel - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } }
From source file:com.notalenthack.blaster.BluetoothSerialService.java
/** * Start the ConnectedThread to begin managing a Bluetooth connection * @param socket The BluetoothSocket on which the connection was made * @param device The BluetoothDevice that has been connected *///from w ww. j a v a 2 s. co m public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) { if (D) Log.d(TAG, "connected"); // Cancel the thread that completed the connection if (mConnectThread != null) { mConnectThread.cancel(); mConnectThread = null; } // Cancel any thread currently running a connection if (mConnectedThread != null) { mConnectedThread.cancel(); mConnectedThread = null; } // Start the thread to manage the connection and perform transmissions mConnectedThread = new ConnectedThread(socket); mConnectedThread.start(); // Send the name of the connected device back to the UI Activity Message msg = mHandler.obtainMessage(Constants.MESSAGE_DEVICE_NAME_CMD); Bundle bundle = new Bundle(); bundle.putString(Constants.KEY_DEVICE_NAME, device.getName()); msg.setData(bundle); mHandler.sendMessage(msg); setState(STATE_CONNECTED); }
From source file:biz.bokhorst.bpt.BPTService.java
private void sendMessage(int type, Bundle data) { try {// ww w . j ava 2s.c om if (clientMessenger != null) { try { Message msg = Message.obtain(); msg.what = type; if (data != null) msg.setData(data); clientMessenger.send(msg); } catch (Exception ex) { Toast.makeText(this, ex.toString(), Toast.LENGTH_LONG).show(); } } } catch (Throwable ex) { Log.e("BPT", "sendMessage: " + ex); } }
From source file:com.nextgis.maplibui.service.LayerFillService.java
private void notifyError(String error) { Bundle bundle = new Bundle(); bundle.putString(BUNDLE_MSG_KEY, error); Message msg = new Message(); msg.setData(bundle); mHandler.sendMessage(msg);//from w ww. j a v a2 s . com }
From source file:by.zatta.pilight.MainActivity.java
/** * Send data to the service//from w w w . j av a2 s . c om * * @param intvaluetosend The data to send */ private void sendMessageToService(String switchCommand) { Log.v(TAG, "switchCommand: " + switchCommand); if (mIsBound) { if (mServiceMessenger != null) { try { Bundle bundle = new Bundle(); bundle.setClassLoader(this.getClassLoader()); bundle.putString("command", switchCommand); Message msg_string = Message.obtain(null, ConnectionService.MSG_SWITCH_DEVICE); msg_string.setData(bundle); msg_string.replyTo = mMessenger; mServiceMessenger.send(msg_string); } catch (RemoteException e) { } } } }
From source file:com.first3.viz.download.DownloadManager.java
private void sendProgressUpdate(Resource resource, int progress) { Message m = Message.obtain(null, MSG_STATUS_DOWNLOAD_PROGRESS, progress, 0); Bundle bundle = new Bundle(); bundle.putParcelable(DownloadManager.RESOURCE, resource); m.setData(bundle); sendMsg(m);//from w w w . ja v a 2s . c o m }
From source file:ch.ethz.inf.vs.android.g54.a4.types.Building.java
/** * Asynchronously get free rooms based on floor and time constraints * A message will be dispatched to the handler informing of the status * In case of failure, the exception string is passed through the message key of the bundle * @param f Floor constraint/*from w ww. j av a 2 s .co m*/ * @param start time constraint in quarter hours * @param end time constraint in quarter hours * @param handler Handler that will get the success/failure message with this object */ public void getFreeRoomsAsync(final Floor f, final Float start, final Float end, final Handler handler) { new Thread() { public void run() { Message m = handler.obtainMessage(); try { m.obj = getFreeRoom(f, start, end); m.what = MessageStatus.SUCCESS.ordinal(); } catch (Exception e) { m.what = MessageStatus.FAILURE.ordinal(); Bundle b = new Bundle(); b.putString("message", e.getMessage()); m.setData(b); } finally { handler.sendMessage(m); } } }.start(); }
From source file:com.example.android.BluetoothChat.BluetoothChatService.java
/** * Start the ConnectedThread to begin managing a Bluetooth connection * @param socket The BluetoothSocket on which the connection was made * @param device The BluetoothDevice that has been connected */// w ww . j a v a 2s . c o m public synchronized void connected(BluetoothSocket socket, BluetoothDevice device, final String socketType) { if (D) Log.d(TAG, "connected, Socket Type:" + socketType); // Cancel the thread that completed the connection if (mConnectThread != null) { mConnectThread.cancel(); mConnectThread = null; } // Cancel any thread currently running a connection if (mConnectedThread != null) { mConnectedThread.cancel(); mConnectedThread = null; } // Cancel the accept thread because we only want to connect to one device if (mSecureAcceptThread != null) { mSecureAcceptThread.cancel(); mSecureAcceptThread = null; } if (mInsecureAcceptThread != null) { mInsecureAcceptThread.cancel(); mInsecureAcceptThread = null; } // Start the thread to manage the connection and perform transmissions mConnectedThread = new ConnectedThread(socket, socketType); mConnectedThread.start(); // Send the name of the connected device back to the UI Activity Message msg = mHandler.obtainMessage(BluetoothChat.MESSAGE_DEVICE_NAME); Bundle bundle = new Bundle(); bundle.putString(BluetoothChat.DEVICE_NAME, device.getName()); msg.setData(bundle); mHandler.sendMessage(msg); setState(STATE_CONNECTED); }
From source file:com.samsung.spen.SpenPlugin.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "Inside onActivityResult"); Log.d(TAG, "Intent: " + intent + ", requestCode: " + requestCode); }//w ww . java 2 s . com if (requestCode == Utils.REQUEST_CODE_SELECT_IMAGE_BACKGROUND) { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "on background image selected"); } if (mCurrentSurfaceType == Utils.SURFACE_INLINE) { mSpenSurfaceViews.getSurfaceView(mCurrentWorkingId).setasBgImage(intent); } else { Message msgObj = setBgHandler.obtainMessage(); Bundle b = new Bundle(); b.putParcelable("intent", intent); msgObj.setData(b); setBgHandler.sendMessage(msgObj); } } else { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "request code is not matching"); } } }