Example usage for android.os Message sendToTarget

List of usage examples for android.os Message sendToTarget

Introduction

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

Prototype

public void sendToTarget() 

Source Link

Document

Sends this Message to the Handler specified by #getTarget .

Usage

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(// www  . ja v  a2 s. 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.zuzhili.bussiness.helper.CCPHelper.java

/**
 * send object to activity by handler./*  w  w w .  j  a v  a  2  s . co m*/
 * 
 * @param what
 *            message id of handler
 * @param obj
 *            message of handler
 */
private void sendTarget(int what, Object obj) {
    t = System.currentTimeMillis();
    // for kinds of mobile phones
    while (handler == null && (System.currentTimeMillis() - t < 3200)) {
        Log4Util.d(DEMO_TAG, "[VoiceHelper] handler is null, activity maybe destory, wait...");
        try {
            Thread.sleep(80L);
        } catch (InterruptedException e) {
        }
    }

    if (handler == null) {
        Log4Util.d(DEMO_TAG, "[VoiceHelper] handler is null, need adapter it.");
        return;
    }

    Message msg = Message.obtain(handler);
    msg.what = what;
    msg.obj = obj;
    msg.sendToTarget();
}

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

@Override
public void onTemperatureReading(ThermaSensor 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 = "temperature;" + serialnum + ";" + scan;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(/*ww  w  .j a v a 2s.c om*/
            "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.example.cuisoap.agrimac.homePage.demand.machineSelectDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    View view = inflater.inflate(R.layout.dialog_select_machine, container);
    list = (ListView) view.findViewById(R.id.machine_select_list);
    adapter = new machineSelectAdapter(mContext);
    data = new ArrayList<>();
    list.setAdapter(adapter);/*www. jav a  2 s . co  m*/
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            JSONObject jo = new JSONObject();
            HashMap<String, String> item = (HashMap<String, String>) adapter.getItem(position);
            Intent i = new Intent();
            i.setAction("select_machine");
            i.putExtra("id", item.get("id"));
            i.putExtra("name", item.get("machine_name"));
            mContext.sendBroadcast(i);
            dismiss();
        }
    });
    Message m = Message.obtain();
    JSONObject o = new JSONObject();
    try {
        o.put("status", 0);
        JSONArray oo = new JSONArray("[{\n" + "    \"driveType\": \"\",\n"
                + "    \"driverName\": \"p\",\n" + "    \"driverAge\": \"p\",\n"
                + "    \"driverGender\": \"female\",\n" + "    \"driverLicenseType\": \"R\",\n"
                + "    \"driverLicense\": \"/sdcard/agrimac/driver2016_05_31_09_38_15.png\",\n"
                + "    \"machineType\": \"\",\n" + "    \"machineName\": \"p\",\n"
                + "    \"machinePower\": \"1\",\n" + "    \"passengerNum\": \"1\",\n"
                + "    \"wheelDistance\": \"1\",\n" + "    \"checkTime\": \"1\",\n"
                + "    \"payType\": \"loan\",\n" + "    \"machinePowerType\": \"\",\n"
                + "    \"machineLicense1\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_34.png\",\n"
                + "    \"machineLicense2\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_37.png\",\n"
                + "    \"leaseMonth\": \"1\",\n" + "    \"leaseTime\": \"1\",\n"
                + "    \"workCondition\": \"\",\n" + "    \"needType\": \"all\",\n"
                + "    \"houseType\": \"normal_house\",\n" + "    \"id\": \"1\"\n" + "}]");
        o.put("data", oo);
        m.obj = o;
        m.setTarget(h);
        m.sendToTarget();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return view;
}

From source file:com.dzt.musicplay.player.AudioService.java

private void playNext() {
    Message message = Message.obtain(mPlayFileHandler);
    message.what = 3;
    message.sendToTarget();
}

From source file:com.dzt.musicplay.player.AudioService.java

private void playPrevious() {
    Message message = Message.obtain(mPlayFileHandler);
    message.what = 4;
    message.sendToTarget();
}

From source file:com.example.cuisoap.agrimac.homePage.homeFragment.java

public void test() {
    Message m = Message.obtain();
    JSONObject o = new JSONObject();

    try {// w w  w . ja v  a  2 s  . c  o  m
        o.put("status", 0);
        JSONArray oo = new JSONArray("[{\n" + "    \"driveType\": \"1\",\n" + "    \"driverName\": \"p\",\n"
                + "    \"driverAge\": \"p\",\n" + "    \"driverGender\": \"female\",\n"
                + "    \"licenseType\": \"R\",\n"
                + "    \"driverLicense\": \"/sdcard/agrimac/driver2016_05_31_09_38_15.png\",\n"
                + "    \"machineType\": \"\",\n" + "    \"machineName\": \"p\",\n"
                + "    \"machinePower\": \"1\",\n" + "    \"passengerNum\": \"1\",\n"
                + "    \"wheelDistance\": \"1\",\n" + "    \"checkTime\": \"1\",\n"
                + "    \"payType\": \"loan\",\n" + "    \"machinePowerType\": \"\",\n"
                + "    \"machineLicense1\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_34.png\",\n"
                + "    \"machineLicense2\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_37.png\",\n"
                + "    \"leaseMonth\": \"1\",\n" + "    \"leaseTime\": \"1\",\n"
                + "    \"workCondition\": \"\",\n" + "    \"needType\": \"all\",\n"
                + "    \"houseType\": \"normal_house\",\n" + "    \"id\": \"1\"\n" + "}]");
        o.put("data", oo);
        m.obj = o;
        m.setTarget(h);
        m.sendToTarget();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

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

@Override
public void onClimaPressureUpdate(ClimaSensor clima, SensorReading<Integer> kPa) {
    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_CLIMA_PRESSURE);
    m.getData().putFloat(MessageConstants.FLOAT_VALUE_KEY, kPa.getValue());
    // convert the UTF
    final Context thiscontext = this.getActivity();
    final DecimalFormat formatter = new DecimalFormat("0.00");
    final String serialnumOne = clima.getSerialNumber();
    final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
    final String scann = formatter.format(kPa.getValue());
    String json = "pressure;" + serialnum + ";" + scann;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(/* w ww .  jav  a 2  s. co  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.ClimaFragment.java

@Override
public void onClimaLightUpdate(ClimaSensor clima, SensorReading<Float> lightLevel) {
    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_CLIMA_LIGHT);
    m.getData().putFloat(MessageConstants.FLOAT_VALUE_KEY, lightLevel.getValue());
    // convert the UTF
    final Context thiscontext = this.getActivity();
    final DecimalFormat formatter = new DecimalFormat("0.00");
    final String serialnumOne = clima.getSerialNumber();
    final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
    final String scann = formatter.format(lightLevel.getValue());
    String json = "light;" + serialnum + ";" + scann;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(//from w ww  . ja  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:com.variable.demo.api.fragment.ClimaFragment.java

@Override
public void onClimaHumidityUpdate(ClimaSensor clima, SensorReading<Float> humidityLevel) {
    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_CLIMA_HUMIDITY);
    m.getData().putFloat(MessageConstants.FLOAT_VALUE_KEY, humidityLevel.getValue());
    // convert the UTF
    final Context thiscontext = this.getActivity();
    final DecimalFormat formatter = new DecimalFormat("0.00");
    final String serialnumOne = clima.getSerialNumber();
    final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
    final String scann = formatter.format(humidityLevel.getValue());
    String json = "humidity;" + serialnum + ";" + scann;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(// www .  j  a v a  2  s  .  co 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();
}