Example usage for android.os Message Message

List of usage examples for android.os Message Message

Introduction

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

Prototype

public Message() 

Source Link

Document

Constructor (but the preferred way to get a Message is to call #obtain() Message.obtain() ).

Usage

From source file:com.nextgis.maplibui.service.LayerFillService.java

private void notifyError(String error) {
    Bundle bundle = new Bundle();
    bundle.putString(BUNDLE_MSG_KEY, error);

    Message msg = new Message();
    msg.setData(bundle);/*from  w ww  . j a va2s .  com*/
    mHandler.sendMessage(msg);
}

From source file:com.DGSD.DGUtils.ImageDownloader.ImageLoader.java

public void notifyImageLoaded(String url, Bitmap bitmap) {
    Message message = new Message();
    message.what = HANDLER_MESSAGE_ID;/*  w  w w  . j  ava 2  s  .c o  m*/
    Bundle data = new Bundle();
    data.putString(IMAGE_URL_EXTRA, url);
    Bitmap image = bitmap;
    data.putParcelable(BITMAP_EXTRA, image);
    message.setData(data);

    handler.sendMessage(message);
}

From source file:com.xpg.gokit.activity.GokitControlActivity.java

@Override
public void didQueryHardwareInfo(XPGWifiDevice device, int result,
        java.util.concurrent.ConcurrentHashMap<String, String> hardwareInfo) {
    StringBuilder sb = new StringBuilder();
    if (0 == result) {
        sb.append("Wifi Hardware Version:" + hardwareInfo.get(XPGWifiDevice.XPGWifiDeviceHardwareWifiHardVerKey)
                + "\r\n");
        sb.append("Wifi Software Version:" + hardwareInfo.get(XPGWifiDevice.XPGWifiDeviceHardwareWifiSoftVerKey)
                + "\r\n");
        sb.append("MCU Hardware Version:" + hardwareInfo.get(XPGWifiDevice.XPGWifiDeviceHardwareMCUHardVerKey)
                + "\r\n");
        sb.append("MCU Software Version:" + hardwareInfo.get(XPGWifiDevice.XPGWifiDeviceHardwareMCUSoftVerKey)
                + "\r\n");
        sb.append("Firmware Id:" + hardwareInfo.get(XPGWifiDevice.XPGWifiDeviceHardwareFirmwareIdKey) + "\r\n");
        sb.append("Firmware Version:" + hardwareInfo.get(XPGWifiDevice.XPGWifiDeviceHardwareFirmwareVerKey)
                + "\r\n");
        sb.append("Product Key:" + hardwareInfo.get(XPGWifiDevice.XPGWifiDeviceHardwareProductKey) + "\r\n");
        sb.append("Device id:" + device.getDid() + "\r\n");
    } else {//from   w ww .ja v a  2s  . c o  m
        sb.append("??" + result);
    }

    Message msg = new Message();
    msg.what = HARDWARE;
    msg.obj = sb.toString();
    handler.sendMessage(msg);
}

From source file:com.fanfou.app.opensource.service.DownloadService.java

private void sendProgressMessage(final int progress) {
    final Message message = new Message();
    message.what = DownloadService.MSG_PROGRESS;
    message.arg1 = progress;/*from  w w  w .j av  a  2 s.c om*/
    this.mHandler.sendMessage(message);
}

From source file:com.money.manager.ex.sync.SyncService.java

private boolean sendMessage(SyncServiceMessage message) {
    if (mOutMessenger == null)
        return true;

    Message msg = new Message();
    msg.what = message.code;/*from   www.j  a v a2s.c  o m*/

    try {
        mOutMessenger.send(msg);
    } catch (Exception e) {
        Timber.e(e, "sending message from the sync service");

        return false;
    }
    return true;
}

From source file:com.oasis.sdk.activity.GooglePlayBillingActivity.java

/**
 * ??//from w  w  w  . j  a v  a  2s  .  co  m
 */
private void checkALLOrder(final int index) {
    new Thread(new Runnable() {

        @Override
        public void run() {

            if (oldOrderList == null || oldOrderList.size() <= 0 || index >= oldOrderList.size()) {
                myHandler.sendEmptyMessage(101);//?
                return;
            }

            Purchase purchase = oldOrderList.get(index);
            if (handedOrderIDS.contains(purchase.getOrderId())) {// ?orderid??
                Message msg = new Message();
                msg.what = 98;
                msg.arg1 = index;
                myHandler.sendMessage(msg);//?
                return;
            } else
                handedOrderIDS.add(purchase.getOrderId());

            Message msg = null;

            msg = new Message();
            msg.what = -2;
            msg.obj = getResources()
                    .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_order_notice_old"));// ????
            myHandler.sendMessage(msg);
            int res = -1;
            try {
                res = HttpService.instance().checkPurchaseForGoogle(purchase, GoogleBillingUtils.SEPARATE);

                msg = new Message();
                switch (res) {
                case 1000000://???
                case 1000002://?????2?
                case 1000006://?Google??
                case 1000001://sign?????
                    msg.what = 99;
                    msg.obj = purchase;
                    msg.arg1 = res;
                    myHandler.sendMessage(msg);
                    break;

                default:
                    msg.what = 98;
                    msg.arg1 = index;
                    myHandler.sendMessage(msg);//?
                    break;
                }

            } catch (OasisSdkException e) {// ??
                msg = new Message();
                msg.what = 98;
                msg.arg1 = index;
                myHandler.sendMessage(msg);//?
            } finally {
                try {
                    String[] info = purchase.getDeveloperPayload().split(GoogleBillingUtils.SEPARATE);

                    // ?Mdata???
                    List<String> parameters = new ArrayList<String>();
                    parameters.add("\"uid\":\"" + info[0] + "\"");
                    parameters.add("\"roleid\":\"" + info[2] + "\"");
                    parameters.add("\"serverid\":\"" + info[1] + "\"");
                    if (info.length >= 6 && ("android".equalsIgnoreCase(info[5])
                            || "all".equalsIgnoreCase(info[5]) || "test".equalsIgnoreCase(info[5])))
                        parameters.add("\"servertype\":\"" + info[5] + "\"");
                    else
                        parameters.add("\"servertype\":\"\"");
                    parameters.add("\"product_id\":\"" + purchase.getSku() + "\"");
                    parameters.add("\"payment_channal\":\"mob_google\"");
                    String re = info[4];
                    if (re != null && !TextUtils.isEmpty(re)) {
                        String[] rev = re.split("_");
                        parameters.add("\"cost\":\"" + (rev.length > 0 ? rev[0] : "") + "\"");
                        parameters.add("\"currency\":\"" + (rev.length > 1 ? rev[1] : "") + "\"");
                    } else {
                        parameters.add("\"cost\":\"\"");
                        parameters.add("\"currency\":\"\"");
                    }
                    parameters.add("\"value\":\"\"");
                    if (info.length >= 7)
                        parameters.add("\"oas_order_id\":\"" + info[6] + "\"");
                    else
                        parameters.add("\"oas_order_id\":\"\"");
                    parameters.add("\"third_party_orderid\":\"" + purchase.getOrderId() + "\"");
                    parameters.add("\"result_code\":\"" + res + "\"");
                    parameters.add("\"isreport\":\"" + (PhoneInfo.instance().isTrackAble() ? "Y" : "N") + "\"");

                    List<String> status = new ArrayList<String>();
                    status.add("\"event_type\":\"order\"");
                    ReportUtils.add(ReportUtils.DEFAULTEVENT_ORDER_REPORT_OLD_LOCAL, parameters, status);
                } catch (Exception e) {
                    BaseUtils.logError(TAG, "Google play billing send mdata fail.");
                }
            } //end try
        }//end run
    }).start();
}

From source file:com.studio.arm.wink.FaceTrackerActivity.java

@Override
protected void onStart() {
    super.onStart();
    //        if(mCameraSource!=null)
    //            mCameraSource.release();
    //        createCameraSource(flag?CameraSource.CAMERA_FACING_BACK: CameraSource.CAMERA_FACING_FRONT);
    createCameraSource(flag ? CameraSource.CAMERA_FACING_BACK : CameraSource.CAMERA_FACING_FRONT);
    Message msg = new Message();
    msg.obj = FACE_NONE;/*from w w w  .  j ava  2 s. c  om*/
    handler.sendMessage(msg);
    startCameraSource();
}

From source file:com.fanfou.app.opensource.service.DownloadService.java

private void sendSuccessMessage(final File file) {
    final Message message = new Message();
    message.what = DownloadService.MSG_SUCCESS;
    message.getData().putString(Constants.EXTRA_FILENAME, file.getAbsolutePath());
    this.mHandler.sendMessage(message);
}

From source file:cn.xiaocool.android_etong.net.constant.request.MainRequest.java

public void getmyshop() {
    new Thread() {
        Message msg = new Message();

        public void run() {
            String data = "&userid=" + user.getUserId();
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(WebAddress.GETMYSHOP, data);
            Log.e("successful", result_data);
            try {
                JSONObject obj = new JSONObject(result_data);
                msg.what = CommunalInterfaces.GETMYSHOP;
                msg.obj = obj;// w  w w  .  j a v  a 2  s . co m
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}

From source file:com.example.mycar.MainActivity.java

private void ButtonOn() {
    chooseCar.setOnClickListener(new OnClickListener() {

        @Override//  ww  w. j  a  va 2  s  .c o m
        public void onClick(View v) {

            if (mConnected == false) {
                if (du == null) {
                    CustomDialog scanDialog = new CustomDialog(MainActivity.this,
                            CustomDialog.DIALOG_TYPE_SCAN);
                    scanDialog.setScanCallback(new ScanCallback() {

                        @Override
                        public void onName(String name) {

                            device.scan(name);

                        }

                        @Override
                        public void onDevice(final UUID uuid, final String name) {

                            deviceUuid = uuid;
                            devicename = name;
                            edit.putString("nmname", name);
                            edit.putString("duuid", deviceUuid.toString());
                            edit.commit();
                            runOnUiThread(new Runnable() {

                                @Override
                                public void run() {

                                    device.connect(deviceUuid);

                                }
                            });
                        }
                    });

                    scanDialog.show();

                } else {
                    device.connect(UUID.fromString(du));
                }
            } else {
                Toast.makeText(getApplicationContext(), "", Toast.LENGTH_LONG).show();
            }
        }
    });

    chooseCar.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            CustomDialog scanDialog = new CustomDialog(MainActivity.this, CustomDialog.DIALOG_TYPE_SCAN);
            scanDialog.setScanCallback(new ScanCallback() {

                @Override
                public void onName(String name) {

                    device.scan(name);

                }

                @Override
                public void onDevice(final UUID uuid, final String name) {

                    deviceUuid = uuid;
                    devicename = name;
                    edit.putString("nmname", name);
                    edit.putString("duuid", deviceUuid.toString());
                    edit.commit();
                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            device.connect(deviceUuid);
                        }
                    });
                }
            });
            scanDialog.show();
            return false;
        }
    });

    leftAdd.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            if (luonTouch == true) {
                int ea = event.getAction();
                switch (ea) {
                case MotionEvent.ACTION_DOWN:
                    ldonTouch = false;
                    msg = new Message();
                    msg.what = 2;
                    ti.mHandler.sendMessage(msg);
                    break;
                case MotionEvent.ACTION_UP:
                    msg = new Message();
                    msg.what = 14;
                    ti.mHandler.sendMessage(msg);
                    ldonTouch = true;
                    break;
                }
            }
            return false;
        }
    });

    rightAdd.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            if (ruonTouch == true) {
                int ea = event.getAction();
                switch (ea) {
                case MotionEvent.ACTION_DOWN:
                    rdonTouch = false;
                    msg = new Message();
                    msg.what = 1;
                    ti.mHandler.sendMessage(msg);
                    break;
                case MotionEvent.ACTION_UP:
                    msg = new Message();
                    msg.what = 11;
                    ti.mHandler.sendMessage(msg);
                    rdonTouch = true;
                    break;
                }
            }
            return false;
        }
    });

    leftCut.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            if (ldonTouch == true) {
                int ea = event.getAction();
                switch (ea) {
                case MotionEvent.ACTION_DOWN:
                    luonTouch = false;
                    msg = new Message();
                    msg.what = 4;
                    ti.mHandler.sendMessage(msg);
                    break;
                case MotionEvent.ACTION_UP:
                    msg = new Message();
                    msg.what = 14;
                    ti.mHandler.sendMessage(msg);
                    luonTouch = true;
                    break;
                }
            }
            return false;
        }
    });

    rightCut.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            if (rdonTouch == true) {
                int ea = event.getAction();
                switch (ea) {
                case MotionEvent.ACTION_DOWN:
                    ruonTouch = false;
                    msg = new Message();
                    msg.what = 3;
                    ti.mHandler.sendMessage(msg);
                    break;
                case MotionEvent.ACTION_UP:
                    msg = new Message();
                    msg.what = 11;
                    ti.mHandler.sendMessage(msg);
                    ruonTouch = true;
                    break;
                }
            }
            return false;
        }
    });
}