List of usage examples for android.os Message setData
public void setData(Bundle data)
From source file:com.aquatest.dbinterface.tools.DatabaseUpdater.java
/** * Send message from this thread using preset handler * /*from w w w .ja va 2 s . c o m*/ * @param b * message data to be sent * @param _code * code of the message for handler to be able to determine the * type of message */ public void sendMessage(Bundle b, int code) { if (h != null) { Message msg = new Message(); msg.setData(b); msg.what = code; h.sendMessage(msg); } }
From source file:com.example.android.BluetoothSerial.BluetoothSerialService.java
/** * Indicate that the connection was lost and notify the UI Activity. *//*from w w w . j av a2 s. c om*/ private void connectionLost() { setState(STATE_LISTEN); // Send a failure message back to the Activity Message msg = mHandler.obtainMessage(BluetoothSerial.MESSAGE_TOAST); Bundle bundle = new Bundle(); bundle.putString(BluetoothSerial.TOAST, "Device connection was lost"); msg.setData(bundle); mHandler.sendMessage(msg); }
From source file:com.aquatest.dbinterface.tools.DatabaseUpdater.java
/** * Send message from this thread using preset handler * /* ww w.j a v a2s .c o m*/ * @param s * message to be sent * @param _code * code of the message for handler to be able to determine the * type of message */ public void sendMessage(String s, int code) { Bundle b = new Bundle(); b.putString("msg", s); if (h != null) { Message msg = new Message(); msg.setData(b); msg.what = code; h.sendMessage(msg); } }
From source file:org.ueu.uninet.it.IragarkiOholaKontaktua.java
/** * Deskribapen luzea lortzen da unibertsitatea.net webgunetik * Horretarako hari berri bat erabiltzen da * Prozesua bukatzen denean irudi kargatzaileari ematen zaio abisua layouta prestatzeko */// w w w . j a va2 s . c om private void getTestua() { // TODO iragarkia saretik lortzean arazorik balego handler-era bidali // mezua erabiltzaileari oharra erakusteko // TODO bigeiratu iragarki zerrendan zelan egin den try { final IragarkiEskuratzailea ie = new IragarkiEskuratzailea(); new Thread() { @Override public void run() { Iragarkia iragarkia = ie.getIragarkia(url); Message msg = new Message(); Bundle bundle = new Bundle(); bundle.putString("edukia", iragarkia.edukia); msg.setData(bundle); msg.what = 1; msg.setData(bundle); handler_iragarkia.sendMessage(msg); // Abisua eman irudi kargatzaile hariari testua lortu dela latch.countDown(); // Bide batez progress dialogoa gelditu soilik irudirik ez // dagoenean // bestela irudia eta layout-a prestatu arte itxoingo da if (!irudirik && progressDialog != null && progressDialog.isShowing()) progressDialog.dismiss(); } }.start(); // return iragarkia.edukia; } catch (IllegalThreadStateException e) { handler_iragarkia.sendEmptyMessage(0); } catch (Exception e) { // return ""; handler_iragarkia.sendEmptyMessage(0); } }
From source file:pubsub.io.android.PubsubComm.java
/** * Start the ConnectedThread to begin managing a Bluetooth connection * //from w ww .j a v a 2 s .c om * @param socket * The BluetoothSocket on which the connection was made * @param device * The BluetoothDevice that has been connected */ public synchronized void connected(Socket socket, String sub) { 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(Pubsub.CONNECTED_TO_HOST); Bundle bundle = new Bundle(); bundle.putString(Pubsub.HOST_NAME, socket.getInetAddress().getHostName()); msg.setData(bundle); mHandler.sendMessage(msg); // Notify the activity that subscribes are now safe! mHandler.obtainMessage(Pubsub.SUBSCRIBES).sendToTarget(); setState(STATE_CONNECTED); // Subscribe to the defined sub try { write(PubsubParser.sub(sub).getBytes()); } catch (JSONException e) { e.printStackTrace(); } }
From source file:pl.poznan.put.cs.ify.app.MainActivity.java
public void activateRecipe(String recipe, YParamList requiredParams) { Message msg = Message.obtain(null, ServiceHandler.REGISTER_Recipe); Bundle bundle = new Bundle(); bundle.putString(YRecipesService.Recipe, recipe); bundle.putParcelable(YRecipesService.PARAMS, requiredParams); msg.setData(bundle); try {//from ww w. j a va 2s . co m mService.send(msg); } catch (RemoteException e) { e.printStackTrace(); } }
From source file:com.yunzhi.tcpscclient.TcpChatService.java
public void messageForToast(String m) { Message msg = mHandler.obtainMessage(MainActivity.MESSAGE_TOAST); Bundle bundle = new Bundle(); bundle.putString(MainActivity.TOAST, m); msg.setData(bundle); mHandler.sendMessage(msg);//from w w w. j av a2 s. c o m }
From source file:pl.poznan.put.cs.ify.app.MainActivity.java
public void login(String login, String passwd) { if (mService != null) { Message msg = Message.obtain(); Bundle b = new Bundle(); msg.what = ServiceHandler.REQUEST_LOGIN; b.putString(ServiceHandler.LOGIN, login); b.putString(ServiceHandler.PASSWD, passwd); msg.setData(b); try {//from w w w . j ava 2 s . c om mService.send(msg); } catch (RemoteException e) { e.printStackTrace(); } } }
From source file:org.dvbviewer.controller.service.SyncService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { int intentFlags = intent.getIntExtra(ACTION_EXTRA, 0); Message msg; switch (intentFlags) { case SYNC_CHANNELS: msg = mServiceHandler.obtainMessage(); msg.what = SYNC_CHANNELS;//from w ww. ja v a 2 s .com msg.arg1 = startId; msg.arg2 = flags; msg.setData(intent.getExtras()); mServiceHandler.sendMessage(msg); Log.i("ServiceStartArguments", "Sending: " + msg); break; case SYNC_EPG: msg = mServiceHandler.obtainMessage(); msg.what = SYNC_EPG; msg.arg1 = startId; msg.arg2 = flags; msg.setData(intent.getExtras()); mServiceHandler.sendMessage(msg); Log.i("ServiceStartArguments", "Sending: " + msg); // EpgSyncronizer epgSyncer = new EpgSyncronizer(); // epgSyncer.execute(intent); break; default: stopSelf(); break; } } else { // switch (startId) { // case mChannelSyncId: // // break; // // default: // break; // } } return START_REDELIVER_INTENT; }
From source file:com.example.android.BluetoothSerial.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 *//* w ww .j av a 2 s . c o 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; } // Cancel the accept thread because we only want to connect to one device if (mAcceptThread != null) { mAcceptThread.cancel(); mAcceptThread = 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(BluetoothSerial.MESSAGE_DEVICE_NAME); Bundle bundle = new Bundle(); bundle.putString(BluetoothSerial.DEVICE_NAME, device.getName()); msg.setData(bundle); mHandler.sendMessage(msg); setState(STATE_CONNECTED); }