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:net.carlh.toast.State.java

private void changed(int p) {
    for (Handler h : handlers) {
        Message m = Message.obtain();
        Bundle b = new Bundle();
        b.putInt("property", p);
        m.setData(b);
        h.sendMessage(m);// w  ww  . j  a  va 2s .c  om
    }
}

From source file:com.shafiq.mytwittle.service.BackgroundService.java

private void sendMessageToUI(int intvaluetosend) {
    for (int i = mClients.size() - 1; i >= 0; i--) {
        try {//  w w w  .j a  v  a 2  s .  c om
            // Send data as an Integer
            mClients.get(i).send(Message.obtain(null, MSG_SET_INT_VALUE, intvaluetosend, 0));

            // Send data as a String
            Bundle b = new Bundle();
            b.putString("str1", "ab" + intvaluetosend + "cd");
            Message msg = Message.obtain(null, MSG_SET_STRING_VALUE);
            msg.setData(b);
            mClients.get(i).send(msg);

        } catch (RemoteException e) {
            // The client is dead. Remove it from the list; we are going
            // through the list from back to front so this is safe to do
            // inside the loop.
            mClients.remove(i);
        }
    }
}

From source file:com.example.helloworldlinked.backend.HelloWorldService.java

public void sendMessage(String textMessage) {
    JSONObject jObj = createTextJSONObject(textMessage);
    Bundle providerData = new Bundle(1);
    providerData.putString(BUNDLE_DATA, jObj.toString());
    Message providerMsg = Message.obtain(null, MSG_TO_HELLOWORLDPROVIDERSERVICE, 0, 0);
    providerMsg.setData(providerData);

    sendToProviderService(providerMsg);/*  ww  w . j  av a2s.  co  m*/
}

From source file:com.example.helloworldlinked.backend.HelloWorldService.java

public void sendResetCountMessage() {
    JSONObject jObj = createResetJSONObject();
    Bundle providerData = new Bundle(1);
    providerData.putString(BUNDLE_DATA, jObj.toString());
    Message providerMsg = Message.obtain(null, MSG_TO_HELLOWORLDPROVIDERSERVICE, 0, 0);
    providerMsg.setData(providerData);

    sendToProviderService(providerMsg);//from  ww  w  . j  a  v a  2  s. c om
}

From source file:dk.kk.ibikecphlib.util.HttpUtils.java

public static Message JSONtoUserDataMessage(JsonNode result, UserData userData) {
    Message ret = new Message();
    Bundle data = new Bundle();
    if (result != null) {
        data.putBoolean("success", result.get("success").asBoolean());
        data.putString("info", result.get("info").asText());
        if (result.has("invalid_token")) {
            if (result.get("invalid_token").asBoolean()) {
                data.putBoolean("invalid_token", result.get("invalid_token").asBoolean());
                IBikeApplication.logoutWrongToken();
            }//from   www  .  ja v a2  s . co  m
        }
        if (result != null && result.has("data")) {
            JsonNode dataNode = result.get("data");
            if (dataNode != null) {
                data.putInt("id", dataNode.get("id").asInt());
                data.putString("name", dataNode.get("name").asText());
                data.putString("email", dataNode.get("email").asText());
                if (dataNode.has("image_url"))
                    data.putString("image_url", dataNode.get("image_url").asText());
            }
        }
        ret.setData(data);
    }
    return ret;
}

From source file:org.zywx.wbpalmstar.plugin.chatkeyboard.EUExChatKeyboard.java

private void sendMessageWithType(int msgType, String[] params) {
    if (mHandler == null) {
        return;//from   www .  j  a v  a  2  s .c  o m
    }
    Message msg = new Message();
    msg.what = msgType;
    msg.obj = this;
    Bundle b = new Bundle();
    b.putStringArray(CHATKEYBOARD_FUN_PARAMS_KEY, params);
    msg.setData(b);
    mHandler.sendMessage(msg);
}

From source file:com.tenkiv.tekdaqc.android.services.CommunicationService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    // Extract the service instruction
    final String action = intent.getAction();
    Log.d(TAG, "Received start command: " + action);
    // Build the message parameters
    Bundle extras = intent.getExtras();// www.ja v  a 2s .  c  om
    if (extras == null)
        extras = new Bundle();
    extras.putString(TekCast.EXTRA_SERVICE_ACTION, action);

    // Run each task in a background thread.
    final Message msg = mServiceHandler.obtainMessage();
    msg.arg1 = startId;
    msg.setData(extras);
    Log.d(TAG, "Sending message to background thread.");
    mServiceHandler.sendMessage(msg);
    return Service.START_NOT_STICKY;
}

From source file:net.networksaremadeofstring.cyllell.Search.java

public void PerformSearch(final Boolean Crafted) {
    try {/*w  w  w .  j  av  a 2  s.  c  o  m*/
        threadCut = new Cuts(Search.this);

        dialog = new ProgressDialog(this);
        dialog.setTitle("Chef Search");
        dialog.setMessage("Searching for: " + query + "\n\nPlease wait: Prepping Authentication protocols");
        dialog.setIndeterminate(true);
        dialog.show();

        Thread dataPreload = new Thread() {
            public void run() {
                try {
                    JSONObject Nodes;
                    handler.sendEmptyMessage(200);
                    if (Crafted) {
                        Nodes = threadCut.CraftedSearch(query, index);
                    } else {
                        Nodes = threadCut.Search(query, index);
                    }

                    handler.sendEmptyMessage(201);
                    JSONArray rows = Nodes.getJSONArray("rows");
                    for (int i = 0; i < rows.length(); i++) {
                        //Log.i("URI", ((JSONObject) rows.get(i)).getString("name"));
                        listOfNodes.add(new Node(((JSONObject) rows.get(i)).getString("name"), ""));
                    }
                    handler.sendEmptyMessage(202);
                    handler.sendEmptyMessage(0);
                } catch (Exception e) {
                    Message msg = new Message();
                    Bundle data = new Bundle();
                    data.putString("exception", e.getMessage());
                    msg.setData(data);
                    msg.what = 1;
                    handler.sendMessage(msg);
                }

                return;
            }
        };
        dataPreload.start();

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:cc.wulian.smarthomev5.fragment.singin.handler.DecodeHandler.java

/**
 * Decode the data within the viewfinder rectangle, and time how long it took. For efficiency, reuse the same reader objects from one decode to the next.
 * //from ww  w. jav  a2s  .c  o m
 * @param data
 *          The YUV preview frame.
 * @param width
 *          The width of the preview frame.
 * @param height
 *          The height of the preview frame.
 */
private void decode(byte[] data, int width, int height) {
    long start = System.currentTimeMillis();
    Result rawResult = null;
    // /start rotate 90 2013.02.04///
    if (!CameraManager.get().isLandscape()) {
        byte[] rotatedData = new byte[data.length];
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                int index1 = (x * height + height - y - 1);
                int index2 = (x + y * width);
                if (index1 < rotatedData.length && index2 < data.length) {
                    rotatedData[index1] = data[index2];
                }
            }
        }
        int tmp = width; // Here we are swapping, that's the difference to #11
        width = height;
        height = tmp;
        data = rotatedData;
    }
    // //end rotate////
    PlanarYUVLuminanceSource source = CameraManager.get().buildLuminanceSource(data, width, height);
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
    if (bitmap != null) {
        Log.d(TAG, "decode: bitmap is exists");
    } else {
        Log.d(TAG, "decode: bitmap is null");
    }
    try {
        rawResult = multiFormatReader.decodeWithState(bitmap);
    } catch (ReaderException re) {
        Log.d(TAG, "decode: ", re);
    } finally {
        multiFormatReader.reset();
    }

    if (rawResult != null) {
        long end = System.currentTimeMillis();
        Log.d(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString());
        Message message = Message.obtain(scanHandlerResult.getHandler(), R.id.decode_succeeded, rawResult);
        Bundle bundle = new Bundle();
        bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());

        message.setData(bundle);
        // Log.d(TAG, "Sending decode succeeded message...");
        message.sendToTarget();
    } else {
        Message message = Message.obtain(scanHandlerResult.getHandler(), R.id.decode_failed);
        message.sendToTarget();
    }
}

From source file:com.dgimenesmseii.droideye.CamListActivity.java

@Override
public void BSMsgNotifyData(String did, int type, int param) {
    Log.d("ip", "type:" + type + " param:" + param);
    Bundle bd = new Bundle();
    Message msg = hPPPPMsgHandler.obtainMessage();
    msg.what = type;/*from  ww  w .j a  v  a 2  s  .  c  o m*/
    bd.putInt("msgparam", param);
    bd.putString("did", did);
    msg.setData(bd);
    hPPPPMsgHandler.sendMessage(msg);
    if (type == ContentCommon.PPPP_MSG_TYPE_PPPP_STATUS) {
        intentbrod.putExtra("ifdrop", param);
        sendBroadcast(intentbrod);
    }
}