List of usage examples for android.os Message setData
public void setData(Bundle data)
From source file:com.mediatek.systemupdate.HttpManager.java
private void notifySysoper(int actionType) { try {/* w w w . j a v a 2 s. c o m*/ switch (actionType) { case MSG_DELETE_COMMANDFILE: Message msg = Message.obtain(null, MSG_DELETE_COMMANDFILE); msg.replyTo = mMessenger; Bundle data = new Bundle(); if (data == null) { return; } data.putString(CMD_FILE_KEY, COMMAND_FILE); msg.setData(data); if (mService != null) { mService.send(msg); } break; default: break; } } catch (RemoteException e) { e.printStackTrace(); } }
From source file:com.jkw.smartspeedo.bluetooth_service.java
private void return_helper(char command, int value) { Message msg = mHandle.obtainMessage(update); Bundle bundle = new Bundle(); bundle.putInt(BT_COMMAND, (int) command); bundle.putInt(BT_VALUE, value);//from w w w . j a v a 2 s . com msg.setData(bundle); mHandle.sendMessage(msg); }
From source file:com.jkw.smartspeedo.bluetooth_service.java
/** * Ablauf des Verbindungsaufbau://w ww . j av a 2 s . c o m * 1. Diese Klasse wird in einer externen Activity Instaziert (die externe Activity gibt einen callBackHandle mit) * 2. Die Methode connect() wird aufgerufen mit einer Bluetooth Device ID als Argument * 3. Connect() startet einen neuen Hintergrund Thread: ConnectThread damit das UI nicht einfriert beim verbinden * 4. Der ConnectThread ruft in seinem constructor schon die Android connect API funktion auf * 5. Die Funktion run vom ConnectThread baut dann einen Socket auf. Wenn das klappt wird ein weiterer neuer Thread vom Typ ConnectedThread gestartet connectThread ist damit zuende und luft aus * 7. Der ConnectedThread ffnet den Socket und luft auf ewig in einer Endlosschleife und wartet auf neue Daten * * Ablauf des Empfangens: * 1. Der ConnectedThread liest Daten ein und schickt diese byte fr byte an process_incoming() * 2. wenn die checksumme stimmt und die daten vollstndig sind werden sie ber den handle zurck an die Activity geschickt * * Ablauf des Sendens: * 1. send_save bekommt ein command, ein timeout und die anzahl an retries mit geliefert * 2. send_save ruft mit command und timeout send() auf * 2.1 send holt sich als erstes einen semaphore * 2.2 send_save muss warten weil es versucht sich den zweiten semaphore zu holen (es gibt nur einen und den hat send) * 3. send erstellt aus der payload ein packet und schreibt es auf den ConnectedThread, gleichzeitig wird ein timer gestartet * 4.1.1 wenn keine daten zurck kommen luft der timer ab und gibt einen semaphore frei (den send geholt hatte) dadurch wird send_save wieder aktiv * 4.1.2 send_save gibt den semaphore zurck und versucht den vorgang erneut (wenn die anzahl der retries es zulsst) * 4.2.1 wenn eine antwort kommt wird sie von process_incoming() empfangen und der semaphore wird zurck gegeben (den send geholt hatte) */ public bluetooth_service(Handler mBluetoothHandle, Context applicationContext) { mHandle = mBluetoothHandle; mContext = applicationContext; // prepare bluetooth mAdapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported if (mAdapter == null) { Toast.makeText(mContext, "Bluetooth is not available", Toast.LENGTH_LONG).show(); } else { if (!mAdapter.isEnabled()) { Message msg = mHandle.obtainMessage(short_name); Bundle bundle = new Bundle(); bundle.putString(BT_ACTION, ENABLE_BT); // TODO msg.setData(bundle); mHandle.sendMessage(msg); } } ; mState = STATE_NONE; // mSensors = new Sensors(this); }
From source file:au.com.infiniterecursion.vidiom.utils.PublishingUtils.java
public void asyncYouTubeUpload(final Activity activity, final File file, final Handler handler, final String emailAddress, final long sdrecord_id) { new Thread(new Runnable() { public void run() { Message msg = new Message(); Bundle bundle = new Bundle(); msg.setData(bundle); String videoId = null; int submitCount = 0; try { while (submitCount <= MAX_RETRIES && videoId == null) { try { submitCount++;/* ww w .j a va 2 s .c om*/ videoId = startYouTubeUpload(activity, file, handler, emailAddress, sdrecord_id); assert videoId != null; } catch (Internal500ResumeException e500) { // TODO - // this // should // not // really // happen if (submitCount < MAX_RETRIES) { Log.w(TAG, e500.getMessage()); Log.d(TAG, String.format("Upload retry :%d.", submitCount)); } else { Log.d(TAG, "Giving up"); Log.e(TAG, e500.getMessage()); throw new IOException(e500.getMessage()); } } } } catch (IOException e) { e.printStackTrace(); Log.e(TAG, "AsyncYouTubeUpload ERROR - finishing"); return; } catch (YouTubeAccountException e) { e.printStackTrace(); Log.e(TAG, "AsyncYouTubeUpload ERROR - finishing"); return; } catch (SAXException e) { e.printStackTrace(); Log.e(TAG, "AsyncYouTubeUpload ERROR - finishing"); } catch (ParserConfigurationException e) { e.printStackTrace(); Log.e(TAG, "AsyncYouTubeUpload ERROR - finishing"); } } }).start(); }
From source file:com.jkw.smartspeedo.bluetooth_service.java
/** * Set the current state of the connection * @param state An integer defining the current connection state *//*ww w . j a v a 2 s . c o m*/ public synchronized void setState(int state) { Log.i(TAG, "Setting state to " + String.valueOf(state)); mState = state; // Give the new state to the Handler so the UI Activity can update Message msg = mHandle.obtainMessage(short_name); Bundle bundle = new Bundle(); bundle.putString(BT_ACTION, BT_STATE_CHANGE); bundle.putInt(BT_STATE_CHANGE, (int) state); msg.setData(bundle); mHandle.sendMessage(msg); if (state == STATE_CONNECTED) { rx_tx_state = ST_IDLE; } ; }
From source file:com.dzt.musicplay.player.AudioService.java
private void showToast(String text, int duration) { Message msg = new Message(); Bundle bundle = new Bundle(); bundle.putString("text", text); bundle.putInt("duration", duration); msg.setData(bundle); msg.what = SHOW_TOAST;// ww w .j a v a 2s .c om mHandler.sendMessage(msg); }
From source file:com.dzt.musicplay.player.AudioService.java
private void playIndex(int position) { Message message = Message.obtain(mPlayFileHandler); Bundle data = new Bundle(); data.putInt("position", position); message.what = 2;//from w w w . ja v a 2 s. c o m message.setData(data); message.sendToTarget(); }
From source file:com.nbplus.iotapp.service.IoTService.java
public void handleMessage(Message msg) { if (msg == null) { return;// ww w .j av a2s . c om } Log.d(TAG, "handle message msg.what = " + msg.what); switch (msg.what) { // when using iot gateway case IoTServiceCommand.IOT_GATEWAY_CONNECTED: { Log.d(TAG, "IoTServiceCommand.IOT_GATEWAY_CONNECTED received..."); mIoTGatewayWorkerMessengerRef = new WeakReference<>(msg.replyTo); // TODO : test handler if (mIoTGatewayWorkerMessengerRef != null) { try { Messenger workerMessenger = mIoTGatewayWorkerMessengerRef.get(); if (workerMessenger != null) { Message testMsg = new Message(); msg.what = IoTServiceCommand.IOT_GATEWAY_DISCONNECTED; Log.d(TAG, "test IoTServiceCommand.IOT_GATEWAY_DISCONNECTED"); workerMessenger.send(testMsg); } } catch (Exception e) { e.printStackTrace(); } } break; } case IoTServiceCommand.SCANNING_START: { Bundle extras = msg.getData(); if (extras == null) { Log.w(TAG, "Scanning bundle data is not found !!!"); return; } boolean isPeriodic = extras.getBoolean(IoTServiceCommand.KEY_DATA); Log.d(TAG, "IoTServiceCommand.SCANNING_START called. periodic = " + isPeriodic); if (mUseIoTGateway) { } else { if (mBluetoothLeService != null && mServiceStatus == IoTServiceStatus.RUNNING) { mIsBleScanPeriodic = isPeriodic; mBluetoothLeService.scanLeDevicePeriodically(true, isPeriodic); } } break; } case IoTServiceCommand.SCANNING_STOP: { Bundle extras = msg.getData(); if (extras == null) { Log.w(TAG, "Scanning bundle data is not found !!!"); return; } //boolean isPeriodic = extras.getBoolean(IoTServiceCommand.KEY_DATA); Log.d(TAG, "IoTServiceCommand.SCANNING_STOP called."); if (mUseIoTGateway) { } else { if (mBluetoothLeService != null && mServiceStatus == IoTServiceStatus.RUNNING) { mIsBleScanPeriodic = false; mBluetoothLeService.scanLeDevicePeriodically(false, false); } } break; } case HANDLER_MESSAGE_CONNECTIVITY_CHANGED: final boolean isConnected = NetworkUtils.isConnected(this); Log.d(TAG, "HANDLER_MESSAGE_CONNECTIVITY_CHANGED received isConnected = " + isConnected); if (mLastConnectionStatus == isConnected) { Log.d(TAG, "mLastConnectionStatus == isConnected do not anything."); return; } mLastConnectionStatus = isConnected; if (mLastConnectionStatus) { Log.d(TAG, "HANDLER_MESSAGE_CONNECTIVITY_CHANGED network is connected !!!"); // TODO : re-connect if (mServiceStatus == IoTServiceStatus.STOPPED) { } } else { Log.d(TAG, "HANDLER_MESSAGE_CONNECTIVITY_CHANGED network is disconnected !!!"); } break; case HANDLER_MESSAGE_BT_STATE_CHANGED: Log.d(TAG, "HANDLER_MESSAGE_CONNECTIVITY_CHANGED received !!!"); final int state = msg.arg1; if ((mLastConnectionStatus && state == BluetoothAdapter.STATE_ON) || (!mLastConnectionStatus && state == BluetoothAdapter.STATE_OFF)) { return; } mLastConnectionStatus = (state == BluetoothAdapter.STATE_ON) ? true : false; if (mLastConnectionStatus) { Log.d(TAG, "HANDLER_MESSAGE_BT_STATE_CHANGED bluetooth is enabled !!!"); if (mServiceStatus != IoTServiceStatus.RUNNING) { final Intent gattServiceIntent = new Intent(this, BluetoothLeService.class); if (!bindService(gattServiceIntent, mBluetoothServiceConnection, BIND_AUTO_CREATE)) { Log.e(TAG, ">> bind BluetoothServiceConnection failed.... !!!"); } } } else { Log.d(TAG, "HANDLER_MESSAGE_BT_STATE_CHANGED bluetooth is disabled !!!"); mErrorCodes = IoTResultCodes.BLUETOOTH_NOT_ENABLED; unbindService(mBluetoothServiceConnection); mServiceStatus = IoTServiceStatus.STOPPED; mHandler.removeMessages(HANDLER_MESSAGE_CONNECTION_NOT_RESPOND); mConnectedDeviceList.clear(); mRequestHandleMap.clear(); sendServiceStatusNotification(); } break; case IoTServiceCommand.REGISTER_SERVICE: { Bundle b = msg.getData(); if (msg.replyTo == null || b == null) { Log.e(TAG, "Invalid register args..."); break; } String msgId = b.getString(IoTServiceCommand.KEY_MSGID, ""); if (!StringUtils.isEmptyString(msgId)) { Log.d(TAG, "msgId == " + msgId); String[] strArrays = msgId.split("_"); if (strArrays.length == 2) { mRegisteredAppMessenger = new WeakReference<>(msg.replyTo); sendResultToApplication(msg.replyTo, msgId, null, msg.what, IoTResultCodes.SUCCESS); // ?? ?? ? ? . sendServiceStatusNotification(); } else { Log.e(TAG, "Invalid register args..."); sendResultToApplication(msg.replyTo, msgId, null, msg.what, IoTResultCodes.INVALID_REQUEST_ARGUMENTS); break; } } else { Log.e(TAG, "Invalid register args..."); sendResultToApplication(msg.replyTo, "", null, msg.what, IoTResultCodes.INVALID_REQUEST_ARGUMENTS); break; } break; } case IoTServiceCommand.UNREGISTER_SERVICE: { Bundle b = msg.getData(); if (b == null) { Log.e(TAG, "Invalid register args..."); break; } String msgId = b.getString(IoTServiceCommand.KEY_MSGID, ""); if (!StringUtils.isEmptyString(msgId)) { String[] strArrays = msgId.split("_"); if (strArrays.length == 2) { Messenger clientMessenger = (mRegisteredAppMessenger == null) ? null : mRegisteredAppMessenger.get(); if (clientMessenger != null) { sendResultToApplication(clientMessenger, msgId, null, msg.what, IoTResultCodes.SUCCESS); mRegisteredAppMessenger = null; } else { //?? } } else { Log.e(TAG, "Invalid register args..."); break; } } else { Log.e(TAG, "Invalid un-register args..."); } break; } case IoTServiceCommand.GET_DEVICE_LIST: { if (mUseIoTGateway) { // TODO } else { mBluetoothLeService.scanLeDevice(false); mBluetoothLeService.scanLeDevicePeriodically(true, mIsBleScanPeriodic); } break; } case IoTServiceCommand.DEVICE_DISCONNECT_ALL: { Bundle b = msg.getData(); String msgId = b.getString(IoTServiceCommand.KEY_MSGID, ""); b.setClassLoader(IoTHandleData.class.getClassLoader()); IoTHandleData ioTHandleData = b.getParcelable(IoTServiceCommand.KEY_DATA); if (mConnectedDeviceList.size() > 0) { mIsDisconnectAllState = true; ioTHandleData.setMsgId(msgId); ioTHandleData.setRequestCommand(msg.what); String connectedDeviceId = mConnectedDeviceList.get(0); if (mUseIoTGateway) { // TODO } else { if (mBluetoothLeService != null) { mBluetoothLeService.disconnect(connectedDeviceId); } else { Messenger clientMessenger = (mRegisteredAppMessenger == null) ? null : mRegisteredAppMessenger.get(); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); } } } else { Messenger clientMessenger = (mRegisteredAppMessenger == null) ? null : mRegisteredAppMessenger.get(); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.SUCCESS); } break; } case IoTServiceCommand.DEVICE_CONNECT: { Bundle b = msg.getData(); b.setClassLoader(IoTHandleData.class.getClassLoader()); IoTHandleData ioTHandleData = b.getParcelable(IoTServiceCommand.KEY_DATA); String msgId = b.getString(IoTServiceCommand.KEY_MSGID, ""); Messenger clientMessenger = (mRegisteredAppMessenger == null) ? null : mRegisteredAppMessenger.get(); if (ioTHandleData == null) { sendResultToApplication(clientMessenger, msgId, null, msg.what, IoTResultCodes.FAILED); Log.w(TAG, "case READ_WRITE_SETNOTI : ioTHandleData is null"); return; } if (mRequestHandleMap.get(ioTHandleData.getDeviceId()) != null) { Log.d(TAG, "Already previous command deviceid = " + ioTHandleData.getDeviceId() + ", command = " + ioTHandleData.getRequestCommand()); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); return; } if (mUseIoTGateway) { } else { if (mBluetoothLeService == null) { sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); Log.w(TAG, "case IoTServiceCommand.DEVICE_CONNECT : mBluetoothLeService or ioTHandleData is null"); return; } if (ioTHandleData.getDeviceTypeId() != IoTDevice.DEVICE_TYPE_ID_BT) { sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); Log.w(TAG, "case IoTServiceCommand.DEVICE_DISCONNECT : is not bt device... mUseIoTGateway == false"); return; } if (ioTHandleData.isKeepAliveDevice()) { if (mKeepAliveConnectionDeviceList.contains(ioTHandleData.getDeviceId())) { Log.d(TAG, "Keep alive device is already connected.. id = " + ioTHandleData.getDeviceId()); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.SUCCESS); // send to IoT interface module Message connectedMsg = new Message(); connectedMsg.what = IoTServiceCommand.DEVICE_CONNECTED; Bundle extras = new Bundle(); extras.putString(IoTServiceCommand.KEY_DEVICE_UUID, ioTHandleData.getDeviceId()); connectedMsg.setData(extras); sendNotificationToApplication(connectedMsg); return; } } if (mBluetoothLeService.connect(ioTHandleData.getDeviceId())) { ioTHandleData.setMsgId(msgId); ioTHandleData.setRequestCommand(msg.what); mRequestHandleMap.put(ioTHandleData.getDeviceId(), ioTHandleData); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.SUCCESS); // ?... connect ? . Message notRespondMsg = new Message(); notRespondMsg.what = HANDLER_MESSAGE_CONNECTION_NOT_RESPOND; Bundle extras = new Bundle(); extras.putParcelable(IoTServiceCommand.KEY_DATA, ioTHandleData); notRespondMsg.setData(extras); mHandler.sendMessageDelayed(notRespondMsg, CONNECTION_NOT_RESPOND_WAIT_TIME); } else { Log.w(TAG, "mBluetoothLeService.connect() return false"); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); } } break; } case HANDLER_MESSAGE_CONNECTION_NOT_RESPOND: { Log.d(TAG, "HANDLER_MESSAGE_CONNECTION_NOT_RESPOND ..."); Bundle b = msg.getData(); b.setClassLoader(IoTHandleData.class.getClassLoader()); IoTHandleData ioTHandleData = b.getParcelable(IoTServiceCommand.KEY_DATA); if (mBluetoothLeService != null) { mBluetoothLeService.disconnect(ioTHandleData.getDeviceId()); } mRequestHandleMap.remove(ioTHandleData.getDeviceId()); Messenger clientMessenger = (mRegisteredAppMessenger == null) ? null : mRegisteredAppMessenger.get(); sendResultToApplication(clientMessenger, ioTHandleData.getMsgId(), ioTHandleData.getDeviceId(), IoTServiceCommand.DEVICE_CONNECT, IoTResultCodes.DEVICE_CONNECTION_NOT_RESPOND); break; } case IoTServiceCommand.DEVICE_DISCONNECT: { Bundle b = msg.getData(); b.setClassLoader(IoTHandleData.class.getClassLoader()); IoTHandleData ioTHandleData = b.getParcelable(IoTServiceCommand.KEY_DATA); String msgId = b.getString(IoTServiceCommand.KEY_MSGID, ""); Messenger clientMessenger = (mRegisteredAppMessenger == null) ? null : mRegisteredAppMessenger.get(); if (ioTHandleData == null) { sendResultToApplication(clientMessenger, msgId, null, msg.what, IoTResultCodes.FAILED); Log.w(TAG, "case READ_WRITE_SETNOTI : ioTHandleData is null"); return; } if (mRequestHandleMap.get(ioTHandleData.getDeviceId()) != null) { Log.d(TAG, "Already previous command deviceid = " + ioTHandleData.getDeviceId() + ", command = " + ioTHandleData.getRequestCommand()); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); return; } if (mUseIoTGateway) { } else { if (mBluetoothLeService == null) { sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); Log.w(TAG, "case IoTServiceCommand.DEVICE_DISCONNECT : mBluetoothLeService or ioTHandleData is null"); return; } if (ioTHandleData.getDeviceTypeId() != IoTDevice.DEVICE_TYPE_ID_BT) { sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); Log.w(TAG, "case IoTServiceCommand.DEVICE_DISCONNECT : is not bt device... mUseIoTGateway == false"); return; } if (mConnectedDeviceList.contains(ioTHandleData.getDeviceId()) || mKeepAliveConnectionDeviceList.contains(ioTHandleData.getDeviceId())) { ioTHandleData.setMsgId(msgId); ioTHandleData.setRequestCommand(msg.what); mRequestHandleMap.put(ioTHandleData.getDeviceId(), ioTHandleData); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.SUCCESS); mBluetoothLeService.disconnect(ioTHandleData.getDeviceId()); } else { Log.w(TAG, "mConnectedDeviceList.contains(ioTHandleData.getDeviceId()) is false"); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); } } break; } case IoTServiceCommand.DEVICE_READ_DATA: case IoTServiceCommand.DEVICE_WRITE_DATA: case IoTServiceCommand.DEVICE_SET_NOTIFICATION: { Bundle b = msg.getData(); b.setClassLoader(IoTHandleData.class.getClassLoader()); IoTHandleData ioTHandleData = b.getParcelable(IoTServiceCommand.KEY_DATA); String msgId = b.getString(IoTServiceCommand.KEY_MSGID, ""); Messenger clientMessenger = (mRegisteredAppMessenger == null) ? null : mRegisteredAppMessenger.get(); if (ioTHandleData == null) { sendResultToApplication(clientMessenger, msgId, null, msg.what, IoTResultCodes.FAILED); Log.w(TAG, "case READ_WRITE_SETNOTI : ioTHandleData is null"); return; } if (mRequestHandleMap.get(ioTHandleData.getDeviceId()) != null) { Log.d(TAG, "Already previous command deviceid = " + ioTHandleData.getDeviceId() + ", command = " + ioTHandleData.getRequestCommand()); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); return; } if (mUseIoTGateway) { } else { if (mBluetoothLeService == null) { sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); Log.w(TAG, "case READ_WRITE_SETNOTI : ioTHandleData is null"); return; } if (ioTHandleData.getDeviceTypeId() != IoTDevice.DEVICE_TYPE_ID_BT) { sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); Log.w(TAG, "case READ_WRITE_SETNOTI : is not bt device... mUseIoTGateway == false"); return; } if (mConnectedDeviceList.contains(ioTHandleData.getDeviceId()) || mKeepAliveConnectionDeviceList.contains(ioTHandleData.getDeviceId())) { ioTHandleData.setMsgId(msgId); ioTHandleData.setRequestCommand(msg.what); boolean result = true; switch (msg.what) { case IoTServiceCommand.DEVICE_READ_DATA: result = mBluetoothLeService.readCharacteristic(ioTHandleData.getDeviceId(), ioTHandleData.getServiceUuid(), ioTHandleData.getCharacteristicUuid()); break; case IoTServiceCommand.DEVICE_WRITE_DATA: result = mBluetoothLeService.writeRemoteCharacteristic(ioTHandleData.getDeviceId(), ioTHandleData.getServiceUuid(), ioTHandleData.getCharacteristicUuid(), ioTHandleData.getValue()); break; case IoTServiceCommand.DEVICE_SET_NOTIFICATION: result = mBluetoothLeService.setCharacteristicNotification(ioTHandleData.getDeviceId(), ioTHandleData.getServiceUuid(), ioTHandleData.getCharacteristicUuid(), true); break; } if (result) { mRequestHandleMap.put(ioTHandleData.getDeviceId(), ioTHandleData); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.SUCCESS); } else { sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); } } else { Log.w(TAG, "mConnectedDeviceList.contains(ioTHandleData.getDeviceId()) is false"); sendResultToApplication(clientMessenger, msgId, ioTHandleData.getDeviceId(), msg.what, IoTResultCodes.FAILED); } } break; } } }
From source file:com.dzt.musicplay.player.AudioService.java
private void readMedia(String filePath, boolean noVideo) { Message message = Message.obtain(mPlayFileHandler); Bundle data = new Bundle(); data.putString("filePath", filePath); data.putBoolean("noVideo", noVideo); message.what = 1;/*from w ww .j a va2 s . c o m*/ message.setData(data); message.sendToTarget(); }
From source file:website.openeng.anki.DeckPicker.java
@Override protected void onCollectionLoaded(Collection col) { // keep reference to collection in parent super.onCollectionLoaded(col); // create backup in background if needed Boolean started = BackupManager.performBackupInBackground(col.getPath()); if (started) { // Themes.showThemedToast(this, getResources().getString(R.string.backup_collection), true); }/* ww w. j av a 2s. co m*/ // Force a full sync if flag was set in upgrade path, asking the user to confirm if necessary if (mRecommendFullSync) { mRecommendFullSync = false; try { col.modSchema(); } catch (ConfirmModSchemaException e) { // If libanki determines it's necessary to confirm the full sync then show a confirmation dialog // We have to show the dialog via the DialogHandler since this method is called via a Loader Resources res = getResources(); Message handlerMessage = Message.obtain(); handlerMessage.what = DialogHandler.MSG_SHOW_FORCE_FULL_SYNC_DIALOG; Bundle handlerMessageData = new Bundle(); handlerMessageData.putString("message", res.getString(R.string.full_sync_confirmation_upgrade) + "\n\n" + res.getString(R.string.full_sync_confirmation)); handlerMessage.setData(handlerMessageData); getDialogHandler().sendMessage(handlerMessage); } } // prepare deck counts and mini-today-statistic updateDeckList(); // Open StudyOptionsFragment if in fragmented mode if (mFragmented) { // Create the fragment in a new handler since Android won't let you perform fragment // transactions in a loader's onLoadFinished. new Handler().post(new Runnable() { public void run() { loadStudyOptionsFragment(false); } }); } hideProgressBar(); automaticSync(); }