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:de.nware.app.hsDroid.logic.LoginThread.java

License:asdf

@Override
public void run() {
    // flags setzen
    mStoppingThread = false;//from w ww  . j  a v a  2 s  . c  o m
    mThreadStatus = STATE_RUNNING;

    // prepare Looper
    Looper.prepare();

    mThreadHandler = new Handler() {
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case HANLDER_MSG_LOGIN:
                try {
                    doLogin();

                } catch (Exception e) {
                    mThreadStatus = STATE_ERROR;
                    Message oMessage = mParentHandler.obtainMessage();
                    Bundle oBundle = new Bundle();
                    String strMessage = e.getMessage();
                    oBundle.putString("Message", strMessage);
                    oMessage.setData(oBundle);
                    oMessage.what = MESSAGE_ERROR;
                    mParentHandler.sendMessage(oMessage);
                } catch (Throwable e) {
                    Log.e("Login Handler", e.getMessage());
                    e.printStackTrace();
                }
                break;

            case HANLDER_MSG_LOGOUT:
                try {
                    doLogout();

                } catch (Exception e) {
                    mThreadStatus = STATE_ERROR;
                    Message oMessage = mParentHandler.obtainMessage();
                    Bundle oBundle = new Bundle();
                    String strMessage = e.getMessage();
                    oBundle.putString("Message", strMessage);
                    oMessage.setData(oBundle);
                    oMessage.what = MESSAGE_ERROR;
                    mParentHandler.sendMessage(oMessage);
                } catch (Throwable e) {
                    Log.e("Login Handler", e.getMessage());
                    e.printStackTrace();
                }
                break;
            case HANLDER_MSG_KILL:
                getLooper().quit();
                break;
            default:
                break;
            }
        }
    };

    Looper.loop();
}

From source file:com.netlinks.healthbracelet.service.HeartRateService.java

/**
 * Indicate that the connection attempt failed and notify the UI Activity.
 *///w w  w  . j av  a 2 s  .co m
private void connectionFailed() {
    setState(STATE_LISTEN);

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

From source file:com.netlinks.healthbracelet.service.HeartRateService.java

/**
 * Indicate that the connection was lost and notify the UI Activity.
 *///from   w w  w  .  jav a2s. c  o m
private void connectionLost() {
    setState(STATE_LISTEN);

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

    this.stop();
    this.BluetoothConfig();
}

From source file:com.example.bikey.BluetoothActivity.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  w w.  j a  v a2 s.c om*/
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(LockPage.MESSAGE_DEVICE_NAME);
    Bundle bundle = new Bundle();
    bundle.putString(LockPage.DEVICE_NAME, device.getName());
    msg.setData(bundle);
    mHandler.sendMessage(msg);

    setState(STATE_CONNECTED);
}

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 button//  w w w.j av a 2 s  .  c o m
 */
public void showNormalErrorDialog() {
    try {
        PhrescoLogger.info(TAG + " processOnComplete - readAppConfigJSON - showErrorDialogHandler :");
        Message msg = new Message();
        Bundle errorMessageBundle = new Bundle();
        errorMessageBundle.putString(errMessage, getString(R.string.http_connect_error_message));
        msg.setData(errorMessageBundle);
        msg.what = ERROR_DIALOG_FLAG;
        showErrorDialogHandler.sendMessage(msg);
    } catch (Exception ex) {
        PhrescoLogger.info(TAG + " - showNormalErrorDialog  - Exception : " + ex.toString());
        PhrescoLogger.warning(ex);
    }
}

From source file:com.netlinks.healthbracelet.service.HeartRateService.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 w  w.j a v a2 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;
    }

    // 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(MESSAGE_DEVICE_NAME);
    Bundle bundle = new Bundle();
    bundle.putString(DEVICE_NAME, device.getName());
    msg.setData(bundle);
    mHandler.sendMessage(msg);

    setState(STATE_CONNECTED);
}

From source file:pl.poznan.put.cs.ify.app.MainActivity.java

public void removeAvailableRecipe(String name) {
    if (mService != null) {
        Message msg = Message.obtain();
        Bundle b = new Bundle();
        msg.what = ServiceHandler.REQUEST_REMOVE_AVAILABLE_RECIPE;
        b.putString(YRecipesService.Recipe, name);
        msg.setData(b);
        try {//from  www .  j a  va2  s  . c o  m
            mService.send(msg);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.notalenthack.blaster.BluetoothSerialService.java

private void sendMessageToast(String msgStr) {
    // Send a failure message back to the Activity
    Message msg = mHandler.obtainMessage(Constants.MESSAGE_TOAST_CMD);
    Bundle bundle = new Bundle();
    bundle.putString(Constants.KEY_TOAST, msgStr);
    msg.setData(bundle);
    mHandler.sendMessage(msg);//from  ww  w. ja  v  a  2  s  .c  om
}

From source file:com.notalenthack.blaster.BluetoothSerialService.java

private void sendMessageBackToUI(String str) {
    // Send a failure message back to the Activity
    Message msg = mHandler.obtainMessage(Constants.MESSAGE_DEVICE_SERIAL_CMD);
    Bundle bundle = new Bundle();
    bundle.putString(Constants.KEY_JSON_STR, str);
    msg.setData(bundle);
    mHandler.sendMessage(msg);//from  ww w  . ja v a  2  s.  c  om
}

From source file:com.example.android.BluetoothSerial.BluetoothSerialService.java

/**
 * Indicate that the connection attempt failed and notify the UI Activity.
 *///from ww w.  j a va 2 s.  c om
private void connectionFailed() {
    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, "Unable to connect device");
    msg.setData(bundle);
    mHandler.sendMessage(msg);
}