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.softminds.matrixcalculator.OperationFragments.AdjointFragment.java

public void RunToGetDeterminant(final int pos, final ProgressDialog px) {
    Runnable runnable = new Runnable() {
        @Override//from  ww  w .j av a2 s .co  m
        public void run() {
            Bundle bundle = SquareList.get(pos).getAdjoint(px).getDataBundled();
            Message message = new Message();
            message.setData(bundle);
            progress = px;
            myhandler.sendMessage(message);

        }
    };
    Thread thread = new Thread(runnable);
    thread.start();
}

From source file:angel.zhuoxiu.library.pusher.PusherChannel.java

public void dispatchEvents(String eventName, String eventData) {
    Bundle data = new Bundle();
    data.putString("eventName", eventName);
    data.putString("eventData", eventData);
    data.putString("channelName", mName);
    Message msg = Message.obtain();
    msg.setData(data);

    for (PusherCallback callback : mGlobalCallbacks) {
        callback.sendMessage(msg);/*from w  ww.  ja v a 2s . co  m*/
    }

    /* do we have a callback bound to that event? */
    if (mLocalCallbacks.containsKey(eventName)) {
        /* execute each callback */
        for (PusherCallback callback : mLocalCallbacks.get(eventName)) {
            callback.sendMessage(msg);
        }
    }

}

From source file:sg.edu.nus.tasklaundrette.ChatMessagingService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    String data = intent.getStringExtra("data_info");

    try {//w w w.j av  a2  s .  co m
        Bundle args = Converter.convertToMessageData(data);
        Message msg = new Message();
        msg.setData(args);

        mMessenger.send(msg);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return START_STICKY;
}

From source file:MyWeatherService.java

void sendWeatherToClient(String actualWeatherString) {
    Bundle reply = new Bundle();
    reply.putString("weather", actualWeatherString);
    Message replyMessage = Message.obtain();
    replyMessage.setData(reply);
    try {/* w  ww  .  j  a  va 2  s .  c om*/
        messengerToClient.send(replyMessage);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}

From source file:com.softminds.matrixcalculator.OperationFragments.ExponentFragment.java

public void RunAndGetResult(final int pos, final int exponent, final ProgressDialog progressDialog) {
    Runnable runnable = new Runnable() {
        @Override//from   ww  w.j a  v  a2  s  . c o m
        public void run() {
            MatrixV2 res = new MatrixV2(
                    ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos)
                            .getNumberOfRows(),
                    ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos)
                            .getNumberOfCols(),
                    ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos).getType());
            res.cloneFrom(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos));
            res.raisedToPower(exponent);
            progressDialog.dismiss();
            Message message = new Message();
            message.setData(res.getDataBundled());
            handler.sendMessage(message);
        }
    };
    Thread thread = new Thread(runnable);
    thread.start();
}

From source file:org.andrico.andrico.UiHandler.java

void executeMethodForMessage(FBMethod m, int messageCode, WriteToProgressHandler progressHandler) {
    HttpResponse response = null;/*from  w  w w .j a va 2 s. c  o  m*/
    try {
        //TODO: mFACEBOOK = NULL!!!!

        response = mFacebook.execute(m, progressHandler);
    } catch (NullPointerException e) {
        // We don't care if we get a npe. the npe will be handled by the handler.
    } finally {
        Bundle bundle = new Bundle();
        bundle.putString("result", HttpResponseRunnable.httpResponseToString(response));
        Message msg = obtainMessage(messageCode);
        msg.setData(bundle);
        sendMessage(msg);
    }
}

From source file:com.ezac.gliderlogs.TimePickerDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    // Creating a bundle object to pass currently set time to the fragment
    Bundle b = getArguments();/*w w  w  . j  a  va 2  s.c  o  m*/
    mHour = b.getInt("set_hour");
    mMinute = b.getInt("set_minute");

    TimePickerDialog.OnTimeSetListener listener = new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            mHour = hourOfDay;
            mMinute = minute;
            // Creating a bundle object to pass currently set time to the fragment
            Bundle b = new Bundle();
            // Adding currently set time to bundle object
            b.putInt("set_hour", mHour);
            b.putInt("set_minute", mMinute);
            // Adding Current time in a string to bundle object
            b.putString("set_time", "Set Time : " + Integer.toString(mHour) + ":" + Integer.toString(mMinute));
            // Creating an instance of Message
            Message m = new Message();
            // Setting bundle object on the message object m
            m.setData(b);
            // Message m is sending using the message handler instantiated in MainActivity class
            mHandler.sendMessage(m);
        }
    };
    // Opening the TimePickerDialog window
    return new TimePickerDialog(getActivity(), listener, mHour, mMinute, true);
}

From source file:com.browsertophone.ShareLink.java

private void sendToast(String toastMessage) {
    Message msg = new Message();
    Bundle data = new Bundle();
    data.putString(TOAST, toastMessage);
    msg.setData(data);
    mHandler.sendMessage(msg);// w  w w .j  a  va2s . c o m
}

From source file:com.espian.ticktock.CountdownFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (getArguments() == null)
        throw new IllegalArgumentException("No args supplied for fragment");

    try {/*ww  w. j a  v a  2s  .  c om*/

        final Date date = DateFormat.getDateInstance(DateFormat.LONG).parse(getArguments().getString("date"));
        mIdAsString = getArguments().getString(BaseColumns._ID);
        mLabelView.setText(mLabel = getArguments().getString("label"));
        mDateView.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date));
        mHelper = new LoadHideHelper(this);

        new Thread(new Runnable() {
            @Override
            public void run() {

                // Requires an ugly fudge because, for some reason, the Days class accesses
                // the disk through random access, which throws errors with StrictMode.
                int days = Days.daysBetween(new DateTime(new Date()), new DateTime(date)).getDays();
                Bundle b = new Bundle();
                b.putString("result", String.valueOf(days + 1));
                Message m = Message.obtain(asyncHandler);
                m.setData(b);
                asyncHandler.sendMessage(m);

            }
        }).start();

    } catch (ParseException e) {
        Toast.makeText(getActivity(), "Malformed date was stored", Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }

    //getActivity().getLoaderManager().initLoader(TickTockProvider.LOADER_SINGLE_ITEM, getArguments(), this);

}

From source file:ServiceConsumerActivity.java

public void queryService() {
    if (isBound) {
        Bundle bundle = new Bundle();
        bundle.putString("location", editText.getText().toString().trim());

        Message message = Message.obtain();
        message.replyTo = messengerFromService;
        message.setData(bundle);
        try {// w  w w .  jav  a2 s .c o  m
            messengerToService.send(message);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    } else {
        textView.setText(R.string.report_appears_here);
        doToast(R.string.service_not_bound);
    }
}