Example usage for android.os Message setData

List of usage examples for android.os Message setData

Introduction

In this page you can find the example usage for android.os Message setData.

Prototype

public void setData(Bundle data) 

Source Link

Document

Sets a Bundle of arbitrary data values.

Usage

From source file:com.yangtsaosoftware.pebblemessenger.activities.ToolsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    switch (requestCode) {
    case REQUEST_SEND_MESSAGE: {
        Message msg = Message.obtain();
        Bundle b = new Bundle();
        msg.what = MessageProcessingService.MSG_NEW_MESSAGE;
        b.putString(MessageDbHandler.COL_MESSAGE_APP, LOG_TAG);
        b.putString(MessageDbHandler.COL_MESSAGE_CONTENT, data.getStringExtra(MESSAGE_BODY));
        try {/*w w  w.  j a v  a2s . c o m*/
            msg.setData(b);
            rMessageProcessHandler.send(msg);
        } catch (RemoteException e) {
            e.printStackTrace();
            Constants.log(LOG_TAG, "Error when sending message to MessageProcessingService.");
        }
        Toast.makeText(_context, R.string.tools_toast_send_message, Toast.LENGTH_LONG).show();
    }
        break;
    case REQUEST_SEND_CALL:
        Intent inner_intent = new Intent(MessageProcessingService.class.getName());
        inner_intent.putExtra(Constants.BROADCAST_COMMAND, Constants.BROADCAST_CALL_INCOMING);
        inner_intent.putExtra(Constants.BROADCAST_PHONE_NUM, data.getStringExtra(CALL_NUM));
        inner_intent.putExtra(Constants.BROADCAST_NAME, data.getStringExtra(CALL_NAME));
        LocalBroadcastManager.getInstance(getActivity().getBaseContext()).sendBroadcast(inner_intent);
        Toast.makeText(_context, R.string.tools_toast_send_call, Toast.LENGTH_LONG).show();
        break;
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.example.sajid.myapplication.ChatConnection.java

public synchronized void updateMessages(String msg, boolean local) {
    Log.e(TAG, "Updating message: " + msg);

    Bundle messageBundle = new Bundle();
    messageBundle.putString("msg", msg);
    byte[] bytes = new byte[0];

    Message message = new Message();
    message.setData(messageBundle);
    mUpdateHandler.sendMessage(message);

}

From source file:com.first3.viz.download.DownloadManager.java

private void sendDownloadSuccessMsg(Resource resource) {
    Bundle bundle = new Bundle();
    bundle.putParcelable(DownloadManager.RESOURCE, resource);
    Message m = Message.obtain(null, MSG_STATUS_DOWNLOAD_SUCCESS);
    m.setData(bundle);
    sendMsg(m);//from   www .j a v a  2s .  com
}

From source file:org.bwgz.quotation.activity.QuotationActivity.java

private void stopLoadMessage() {
    Bundle bundle = new Bundle();
    bundle.putString(LOAD_STATE, LoadState.LOADED.toString());
    Message message = new Message();
    message.setData(bundle);
    lazyLoadMessageHandler.sendMessage(message);
}

From source file:com.cognizant.glass.bluetoothconnect.DemoAppRecieverService.java

/**
 * Indicate that the connection was lost and notify the UI Activity.
 *///from   w w  w.j  ava 2s.  c om
private void connectionLost() {
    // Send a failure message back to the Activity
    final Message msg = mHandler.obtainMessage(MESSAGE_TOAST);
    Bundle bundle = new Bundle();
    bundle.putString(TOAST, "Device connection was lost");
    msg.setData(bundle);
    mHandler.sendMessage(msg);
}

From source file:com.first3.viz.download.DownloadManager.java

private void sendDownloadFailedMsg(Resource resource) {
    Bundle bundle = new Bundle();
    bundle.putParcelable(DownloadManager.RESOURCE, resource);
    String failureText = getFailureText(resource);
    bundle.putString(FAILURE_TEXT, failureText);
    Message m = Message.obtain(null, MSG_STATUS_DOWNLOAD_FAILED);
    m.setData(bundle);
    sendMsg(m);//from   w ww .  j  a  va2  s  .c o  m
}

From source file:com.example.bikey.BluetoothActivity.java

/**
 * Indicate that the connection attempt failed and notify the UI Activity.
 *//*w  w  w. j ava2s  .  c  o m*/
private void connectionFailed() {
    setState(STATE_LISTEN);

    // Send a failure message back to the Activity
    Message msg = mHandler.obtainMessage(LockPage.MESSAGE_TOAST);
    Bundle bundle = new Bundle();
    bundle.putString(LockPage.TOAST, "Unable to connect device");
    msg.setData(bundle);
    mHandler.sendMessage(msg);
}

From source file:com.example.bikey.BluetoothActivity.java

/**
 * Indicate that the connection was lost and notify the UI Activity.
 *//*from w ww. j  av a 2  s.c o  m*/
private void connectionLost() {
    setState(STATE_LISTEN);

    // Send a failure message back to the Activity
    Message msg = mHandler.obtainMessage(LockPage.MESSAGE_TOAST);
    Bundle bundle = new Bundle();
    bundle.putString(LockPage.TOAST, "Device connection was lost");
    msg.setData(bundle);
    mHandler.sendMessage(msg);
}

From source file:net.networksaremadeofstring.rhybudd.ZenossWidgetGraph.java

private void Refresh() {
    CritCount = 0;//from   w  w  w. j  av  a 2  s .c  o  m
    ErrCount = 0;
    WarnCount = 0;

    ((Thread) new Thread() {
        public void run() {
            try {
                //tempZenossEvents = rhybuddCache.GetRhybuddEvents();
                RhybuddDataSource datasource = new RhybuddDataSource(wContext);
                datasource.open();
                tempZenossEvents = datasource.GetRhybuddEvents();
                datasource.close();
            } catch (Exception e) {
                e.printStackTrace();
                //tempZenossEvents.clear();
                tempZenossEvents = null;
            }

            if (null != tempZenossEvents) {
                //Log.i("CountWidget","Found DB Data!");
                handler.sendEmptyMessage(1);
            }
            /*else
            {
               //Log.i("CountWidget","No DB data found, querying API directly");
               //handler.sendEmptyMessage(2);
               try
               {
                  if(API == null)
                  {
             if(settings.getBoolean("httpBasicAuth", false))
             {
                API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", ""),settings.getString("BAUser", ""), settings.getString("BAPassword", ""));
             }
             else
             {
                API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", ""));
             }
                  }
                          
                  try 
                  {
             if(API != null)
             {
                tempZenossEvents = API.GetRhybuddEvents(true,
                      true,
                      true,
                      false,
                      false,
                      true,
                      null,
                      null);
             }
             else
             {
                tempZenossEvents = null;
                handler.sendEmptyMessage(999);
             }
                  }
                  catch(Exception e)
                  {
             handler.sendEmptyMessage(999);
                  }
               }
               catch(Exception e)
               {
                  e.printStackTrace();
               }
            }*/

            if (tempZenossEvents != null) {
                EventCount = tempZenossEvents.size();

                for (int i = 0; i < EventCount; i++) {
                    if (tempZenossEvents.get(i).getSeverity().equals("5"))
                        CritCount++;

                    if (tempZenossEvents.get(i).getSeverity().equals("4"))
                        ErrCount++;

                    if (tempZenossEvents.get(i).getSeverity().equals("3"))
                        WarnCount++;
                }
                tempZenossEvents = null;
                API = null;
            }

            //No matter what send an update
            //handler.sendEmptyMessage(0);
            Message Msg = new Message();
            Bundle data = new Bundle();
            data.putInt("CritCount", CritCount);
            data.putInt("ErrCount", ErrCount);
            data.putInt("WarnCount", WarnCount);
            Msg.setData(data);
            Msg.what = 1;
            handler.sendMessage(Msg);
        }
    }).start();
}

From source file:com.cognizant.glass.bluetoothconnect.DemoAppRecieverService.java

/**
 * Start the ConnectedThread to begin managing a Bluetooth connection
 * /*from   ww  w .  ja va 2s  . c om*/
 * @param socket
 *            The BluetoothSocket on which the connection was made
 * @param device
 *            The BluetoothDevice that has been connected
 */
public synchronized void connected(final BluetoothSocket socket, BluetoothDevice device) {
    if (D)
        Log.d(TAG, "connected");

    // Start the thread to manage the connection and perform transmissions
    mConnectedThread = new ConnectedThread(socket);
    mConnectedThread.start();
    // Add each connected thread to an array
    mConnThreads.add(mConnectedThread);
    // Send the name of the connected device back to the UI Activity
    final Message msg = mHandler.obtainMessage(MESSAGE_DEVICE_NAME);
    Bundle bundle = new Bundle();
    bundle.putString(Constants.DEVICENAME, device.getName());
    msg.setData(bundle);
    mHandler.sendMessage(msg);
}