Example usage for android.os Message getData

List of usage examples for android.os Message getData

Introduction

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

Prototype

public Bundle getData() 

Source Link

Document

Obtains a Bundle of arbitrary data associated with this event, lazily creating it if necessary.

Usage

From source file:id.nci.stm_9.KeychainIntentServiceHandler.java

@Override
public void handleMessage(Message message) {
    Bundle data = message.getData();

    switch (message.arg1) {
    case MESSAGE_OKAY:
        mProgressDialogFragment.dismiss();

        break;//from w  w  w.  j a  v  a2 s .  c  om

    case MESSAGE_EXCEPTION:
        mProgressDialogFragment.dismiss();

        // show error from service
        if (data.containsKey(DATA_ERROR)) {
            Toast.makeText(mActivity, mActivity.getString(R.string.error_message, data.getString(DATA_ERROR)),
                    Toast.LENGTH_SHORT).show();
        }

        break;

    case MESSAGE_UPDATE_PROGRESS:
        if (data.containsKey(DATA_PROGRESS) && data.containsKey(DATA_PROGRESS_MAX)) {

            // update progress from service
            if (data.containsKey(DATA_MESSAGE)) {
                mProgressDialogFragment.setProgress(data.getString(DATA_MESSAGE), data.getInt(DATA_PROGRESS),
                        data.getInt(DATA_PROGRESS_MAX));
            } else if (data.containsKey(DATA_MESSAGE_ID)) {
                mProgressDialogFragment.setProgress(data.getInt(DATA_MESSAGE_ID), data.getInt(DATA_PROGRESS),
                        data.getInt(DATA_PROGRESS_MAX));
            } else {
                mProgressDialogFragment.setProgress(data.getInt(DATA_PROGRESS), data.getInt(DATA_PROGRESS_MAX));
            }
        }

        break;

    default:
        break;
    }
}

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

/**
 * @param msg//from w w w .j  a  v a2  s . co  m
 * @return The error code if there was a facebook problem, null if it was
 *         OK, -1 if there was an internal error.
 */
Integer parseErrorCodeInMessage(Message msg) {
    return JsonParser.parseForErrorCode(msg.getData().getString("result"));
}

From source file:org.planetmono.dcuploader.SignOnRealName.java

public Runnable getMethodSignOff(final Application app, final Handler resultHandler) {
    return new Runnable() {
        public void run() {
            // AFAIK there is no way to sign off. Let the session die alone...
            Message m = resultHandler.obtainMessage();
            m.getData().putBoolean("result", true);
            resultHandler.handleMessage(m);
        }//  w  ww.j a  v a2  s  .  co  m
    };
}

From source file:org.thialfihar.android.apg.service.ApgIntentServiceHandler.java

@Override
public void handleMessage(Message message) {
    Bundle data = message.getData();

    switch (message.arg1) {
    case MESSAGE_OKAY:
        mProgressDialogFragment.dismissAllowingStateLoss();

        break;//from  w  w w  . j a  v  a  2  s .  c  o  m

    case MESSAGE_EXCEPTION:
        mProgressDialogFragment.dismissAllowingStateLoss();

        // show error from service
        if (data.containsKey(DATA_ERROR)) {
            Toast.makeText(mActivity, mActivity.getString(R.string.error_message, data.getString(DATA_ERROR)),
                    Toast.LENGTH_SHORT).show();
        }

        break;

    case MESSAGE_UPDATE_PROGRESS:
        if (data.containsKey(DATA_PROGRESS) && data.containsKey(DATA_PROGRESS_MAX)) {

            // update progress from service
            if (data.containsKey(DATA_MESSAGE)) {
                mProgressDialogFragment.setProgress(data.getString(DATA_MESSAGE), data.getInt(DATA_PROGRESS),
                        data.getInt(DATA_PROGRESS_MAX));
            } else if (data.containsKey(DATA_MESSAGE_ID)) {
                mProgressDialogFragment.setProgress(data.getInt(DATA_MESSAGE_ID), data.getInt(DATA_PROGRESS),
                        data.getInt(DATA_PROGRESS_MAX));
            } else {
                mProgressDialogFragment.setProgress(data.getInt(DATA_PROGRESS), data.getInt(DATA_PROGRESS_MAX));
            }
        }

        break;

    default:
        break;
    }
}

From source file:com.variable.demo.api.fragment.ThermoCoupleFragment.java

@Override
public void onThermoCoupleReading(ThermocoupleSensor sensor, SensorReading<Float> reading) {
    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_THERMA_TEMPERATURE);
    m.getData().putFloat(MessageConstants.FLOAT_VALUE_KEY, reading.getValue());
    final Context thiscontext = this.getActivity();
    final String serialnumOne = sensor.getSerialNumber();
    final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
    final String scan = Float.toString(reading.getValue());
    String json = "thermocouple;" + serialnum + ";" + scan;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(/* ww w.  j  av a 2s .c  o  m*/
            "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]="
                    + json)
            .setLogging("MyLogs", Log.DEBUG).asString().withResponse()
            .setCallback(new FutureCallback<Response<String>>() {
                @Override
                public void onCompleted(Exception e, Response<String> result) {
                    if (e == null) {
                        Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString());
                    } else {
                        Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION");
                        e.printStackTrace();
                    }
                }
            });
    m.sendToTarget();
}

From source file:com.variable.demo.api.fragment.OxaFragment.java

@Override
public void onOxaUpdate(OxaSensor sensor, SensorReading<Float> reading) {
    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_OXA_READING);
    m.getData().putFloat(MessageConstants.FLOAT_VALUE_KEY, reading.getValue());
    final Context thiscontext = this.getActivity();
    final String serialnumOne = sensor.getSerialNumber();
    final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
    final String scan = Float.toString(reading.getValue());
    String json = "oxygen;" + serialnum + ";" + scan;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(//from w  w  w.j  a  va  2s .c  o m
            "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]="
                    + json)
            .setLogging("MyLogs", Log.DEBUG).asString().withResponse()
            .setCallback(new FutureCallback<Response<String>>() {
                @Override
                public void onCompleted(Exception e, Response<String> result) {
                    if (e == null) {
                        Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString());
                    } else {
                        Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION");
                        e.printStackTrace();
                    }
                }
            });
    m.sendToTarget();
}

From source file:org.planetmono.dcuploader.SignOnGallog.java

public Runnable getMethodSignOff(final Application app, final Handler resultHandler) {
    return new Runnable() {
        public void run() {
            HttpGet get = new HttpGet(SIGNOFF_URL + "?s_url=about:blank");
            try {
                app.sendGetRequest(get);
            } catch (Exception e) {
                e.printStackTrace();/*from w  w  w .j av a2s.  c om*/
            }

            Message m = resultHandler.obtainMessage();
            m.getData().putBoolean("result", true);
            resultHandler.handleMessage(m);
        }
    };
}

From source file:org.zywx.wbpalmstar.plugin.inputtextfieldview.EUExInputTextFieldView.java

private void handleOpen(Message msg) {
    String[] params = msg.getData().getStringArray(INPUTTEXTFIELDVIEW_FUN_PARAMS_KEY);
    if (params == null || params.length < 1)
        return;//  w  w w.  j ava2 s . c  o  m
    try {
        if (inputTextFieldView != null)
            return;
        JSONObject json = new JSONObject(params[0]);
        inputTextFieldView = new ACEInputTextFieldView(mContext, json, this);

        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        addView2CurrentWindow(inputTextFieldView, lp);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.zywx.wbpalmstar.plugin.uexCalendarView.EUExCalendarView.java

private void handleInCalendar(Message msg) {
    String[] params = msg.getData().getStringArray(ECalendarViewUtils.CALENDAR_PARAMS_KEY_FUNCTION);
    switch (msg.what) {
    case ECalendarViewUtils.CALENDAR_MSG_CODE_SETSELECTEDDATE:
        handleSetSelectedDate(params);/*from ww  w.  java 2s . c  om*/
        break;
    case ECalendarViewUtils.CALENDAR_MSG_CODE_CLOSE:
        handleClose(params);
        break;
    }
}

From source file:com.fangyuan.vpngate.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from   www. j  av  a 2  s.  c  om

    mContext = this;

    mListView = (ListView) findViewById(R.id.vpn_list);
    mListView.setDividerHeight(16);

    mListItems = new ArrayList<HashMap<String, Object>>();
    SimpleAdapter adapter = new SimpleAdapter(this, mListItems, R.layout.vpn_summary,
            new String[] { "country", "ip" }, new int[] { R.id.country, R.id.ip });
    mListView.setAdapter(adapter);

    hosts = getSharedPreferences("vpngate", MODE_PRIVATE).getString("hosts", null);
    if (hosts != null) {
        parseHostsString(hosts);
    }

    mHandler = new Handler() {
        public void handleMessage(Message msg) {
            hosts = msg.getData().getString("hosts");
            if (hosts != null) {
                if (parseHostsString(hosts)) {
                    SimpleAdapter adapter = (SimpleAdapter) mListView.getAdapter();
                    adapter.notifyDataSetChanged();
                }

            }
            getActionBarHelper().setRefreshActionItemState(false);
        }
    };
}