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.app.jdy.ui.CallBackPasswordActivity.java

public void setCode() {
    String phone = back_password_username.getText().toString().trim();
    String code = back_password_code.getText().toString().trim();
    params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("phone", phone));
    params.add(new BasicNameValuePair("code", code));

    Thread thread = new Thread(new Runnable() {

        @Override/*from  w  w w .  j  av a 2s.  c om*/
        public void run() {
            dataJson = HttpUtils.request(params, URLs.FING_PASSWORD_CHECK_CODE);
            Message msg = new Message();
            if (dataJson.length() != 0 && !dataJson.equals("0x110")) {
                try {
                    jsonObject = new JSONObject(dataJson);
                    if (jsonObject.getBoolean("success")) {
                        msg.what = 3;
                    } else {
                        msg.what = 4;
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            } else {
                msg.what = 0;
            }
            handler.sendMessage(msg);
        }
    });
    thread.start();
}

From source file:net.evecom.androidecssp.gps.EventItemizedOverlayActivity.java

/**
 * /*  w w  w. ja  v  a2  s  .  c o  m*/
 *  
 * 
 * @author Mars zhang
 * @created 2015-12-8 2:48:19
 */
private void initAroundDialog() {
    View dialogView = LayoutInflater.from(EventItemizedOverlayActivity.this).inflate(R.layout.base_wheel_view,
            null);
    dialogNameEd = (EditText) dialogView.findViewById(R.id.base_wheel_view_name_ed);
    //
    WheelView wheelView = (WheelView) dialogView.findViewById(R.id.country);
    wheelView.setVisibleItems(1);
    wheelView.setViewAdapter(new CountryAdapter(EventItemizedOverlayActivity.this, aroundNum));
    wheelView.addScrollingListener(new OnWheelScrollListener() {
        public void onScrollingStarted(WheelView wheel) {
        }

        public void onScrollingFinished(WheelView wheel) {
            aroundChouseValue = aroundNum[tempindex];
        }
    });
    wheelView.addChangingListener(new OnWheelChangedListener() {
        public void onChanged(WheelView wheel, int oldValue, int newValue) {
            tempindex = newValue;
        }
    });
    wheelView.setCurrentItem(3);
    aroundChouseValue = aroundNum[3];
    tempindex = 3;
    //
    resourceType = resourceTypehashmap.keySet().toArray(new String[resourceTypehashmap.size()]);
    WheelView resourceWheelView = (WheelView) dialogView.findViewById(R.id.country_resource_type);
    resourceWheelView.setVisibleItems(1);
    resourceWheelView.setViewAdapter(new CountryAdapter(EventItemizedOverlayActivity.this, resourceType));
    resourceWheelView.addScrollingListener(new OnWheelScrollListener() {
        public void onScrollingStarted(WheelView wheel) {
        }

        public void onScrollingFinished(WheelView wheel) {
            resourceTypeChouseValue = resourceType[resourceTypetempindex];
        }
    });
    resourceWheelView.addChangingListener(new OnWheelChangedListener() {
        public void onChanged(WheelView wheel, int oldValue, int newValue) {
            resourceTypetempindex = newValue;
        }
    });
    if (resourceType.length > 1) {
        resourceWheelView.setCurrentItem(0);
        resourceTypeChouseValue = resourceType[0];
        resourceTypetempindex = 0;
    }
    delDia = new AlertDialog.Builder(EventItemizedOverlayActivity.this)
            .setIcon(R.drawable.qq_dialog_default_icon).setTitle("").setView(dialogView)
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dia, int which) {
                    toast("" + aroundChouseValue + "", 1);
                    if (null != resourceRelativeLayout) {
                        resourceRelativeLayout.setVisibility(View.VISIBLE);
                    }
                    final Message message = new Message();
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            if (null == eventGpsPoints || eventGpsPoints.getGisy() < 1) {
                                return;
                            }
                            HashMap<String, String> mEntityMap = new HashMap<String, String>();
                            int maround = Integer.parseInt(aroundChouseValue);
                            double longdiffer = GpsUtil.getLongDifferFromMeters(mMapView, maround,
                                    EventItemizedOverlayActivity.this,
                                    new GeoPoint((int) (eventGpsPoints.getGisy() * 1E6),
                                            (int) (eventGpsPoints.getGisx() * 1E6)));
                            double latdiffer = GpsUtil.getLatDifferFromMeters(mMapView, maround,
                                    EventItemizedOverlayActivity.this,
                                    new GeoPoint((int) (eventGpsPoints.getGisy() * 1E6),
                                            (int) (eventGpsPoints.getGisx() * 1E6)));
                            mEntityMap.put("longdiffer", longdiffer + "");
                            mEntityMap.put("latdiffer", latdiffer + "");
                            mEntityMap.put("centergisy", eventGpsPoints.getGisy() + "");
                            mEntityMap.put("centergisx", eventGpsPoints.getGisx() + "");
                            mEntityMap.put("pagesize", HttpUtil.getPageSize(instance));
                            mEntityMap.put("resourcename", ifnull(dialogNameEd.getText().toString(), ""));
                            mEntityMap.put("resourcetype",
                                    ifnull(resourceTypehashmap.get(resourceTypeChouseValue), ""));
                            try {
                                String mResult = connServerForResultPost(
                                        "jfs/ecssp/mobile/eventCtr/searchResourceAround", mEntityMap);
                                resourceModels = getObjsInfo(mResult);
                                message.what = MESSAGETYPE_01;
                            } catch (ClientProtocolException e) {
                                message.what = MESSAGETYPE_02;
                            } catch (IOException e) {
                                message.what = MESSAGETYPE_02;
                            } catch (JSONException e) {
                                message.what = MESSAGETYPE_02;
                            }
                            pubhandler.sendMessage(message);
                        }
                    }).start();
                    dia.dismiss();
                }
            }).setNegativeButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dia, int which) {
                    dia.dismiss();
                }
            }).create();
}

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

public void updatausername(final String nicename) {
    new Thread() {
        Message msg = new Message();

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

From source file:com.midooo.ui.activitys.ImageGridFragment.java

private void faXingQuan_getList(String style, String length, String curl, String color, String sex,
        String curpage, String pagesize) {
    RequestParams params = new RequestParams();

    Log.w("---doop---", "start---------faXingQuan_getList-----111----");
    params.put("style", (style == null) ? "0" : style);
    params.put("length", (style == null) ? "0" : style);
    params.put("curl", (style == null) ? "0" : style);
    params.put("color", (style == null) ? "0" : style);
    params.put("sex", (style == null) ? "" : style);
    params.put("curpage", (style == null) ? "1" : style);
    params.put("pagesize", (style == null) ? "10" : style);
    Log.w("---doop---", "start---------faXingQuan_getList----222-----");

    midooRequest.post("/faxingquan/index/getlist", params, new JsonHttpResponseHandler() {//

        Message msg = new Message();

        @Override//from  w  w w  . j  a v  a 2 s. c om
        public void onStart() {
            Log.w("---doop---faXingQuan_getList---", "---onStart---");
        }

        @Override
        public void onFinish() {
            Log.w("---doop---faXingQuan_getList---", "---onFinish---");
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
            Log.w("---doop---", "---onFailure---" + responseString + "------" + statusCode + "------"
                    + throwable.getLocalizedMessage());

        }

        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            Log.w("---doop---", "---onSuccess---" + response.toString() + "------" + statusCode + "------");
            Toast.makeText((FaXingQuanMainActivity) getActivity(), response.toString(), Toast.LENGTH_LONG)
                    .show();

            //JSONArray jsonList;
            try {
                imageUrls = response.getJSONArray("data");

                msg.what = (true) ? 1 : 0;
                msg.obj = (true) ? imageUrls : null;// ?
                /*
                for (int i = 0; i < jsonList.length(); i++) {
                    JSONObject row = jsonList.getJSONObject(i);
                    Log.w("---doop---", "---row---"+row.toString()+"------------");
                    imageUrls.add(row);
                    //name = row.getString("stylephoto");
                }*/
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                msg.what = -1;
                msg.obj = e;
            }
            mHandler.sendMessage(msg);

        }
    });

}

From source file:com.javadog.cgeowear.MobileService.java

@Override
public void onConnected(Bundle bundle) {
    Log.d(DEBUG_TAG, "Connected to Play Services");

    // Start tracking all requested info on the phone side
    locationUtils.startLocationTracking(apiClient);
    if (!useWatchCompass) {
        locationUtils.startDirectionalTracking(getApplicationContext());
    }/*from  www .  ja  v  a 2 s .com*/

    //Get ID of connected Wear device and send it the initial cache info (in another thread)
    new Thread(new Runnable() {
        @Override
        public void run() {
            HashSet<String> connectedWearDevices = new HashSet<>();
            NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(apiClient).await();
            for (Node node : nodes.getNodes()) {
                connectedWearDevices.add(node.getId());
            }

            Message m = new Message();
            try {
                wearInterface = new WearInterface(apiClient, connectedWearDevices.iterator().next());
                wearInterface.initTracking(cacheName, geocode, 0f, 0f, useWatchCompass, geocacheLocation);
                m.obj = MESSAGE_NAVIGATING_NOW;

            } catch (ConnectException e) {
                Log.e(DEBUG_TAG, "Couldn't send initial tracking data.");
                m.obj = MESSAGE_ERROR_COMMUNICATING;

            } catch (NoSuchElementException e) {
                Log.e(DEBUG_TAG, "No Wear devices connected. Killing service...");
                m.obj = MESSAGE_NO_WEAR_DEVICE;

            } finally {
                initThreadHandler.sendMessage(m);
            }
        }
    }).start();
}

From source file:net.evecom.androidecssp.activity.event.EventAddActivity.java

/**
 * /* w  w  w.  ja v a 2  s.  c  o  m*/
 *  postdata
 * 
 * @author Mars zhang
 * @created 2015-11-10 4:13:51
 * @param entity
 */
private void postdata(final HashMap<String, String> entity) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            Message message = new Message();
            try {
                saveResult = connServerForResultPost("jfs/ecssp/mobile/eventCtr/eventAdd", entity);
            } catch (ClientProtocolException e) {
                message.what = MESSAGETYPE_02;
                Log.e("mars", e.getMessage());
            } catch (IOException e) {
                message.what = MESSAGETYPE_02;
                Log.e("mars", e.getMessage());
            }
            if (saveResult.length() > 0) {
                message.what = MESSAGETYPE_01;
                String eventId = "";
                try {
                    BaseModel eventInfo = getObjInfo(saveResult);
                    if (null != eventInfo) {
                        eventId = eventInfo.get("id");
                    }
                } catch (JSONException e) {
                    Log.e("mars", e.getMessage());
                }
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("eventId", eventId);
                postImage(map, filebeans, "jfs/ecssp/mobile/eventCtr/eventFileSave");
            } else {
                message.what = MESSAGETYPE_02;
            }
            Log.v("mars", saveResult);
            saveHandler.sendMessage(message);
        }
    }).start();
}

From source file:com.spoiledmilk.ibikecph.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());
        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());
        }//w  w w.j  a  v  a  2s. com
        ret.setData(data);
    }
    return ret;
}

From source file:cn.laojing.smarthome.VoiceActivity.java

@Override
public void onSpeechFinish(String utteranceId) {
    printe("onSpeechFinish");

    Message msg = new Message();
    msg.what = 0x12;/*from w  ww.j a v  a2s  .c o m*/
    myHandler.sendMessage(msg);
}

From source file:com.wordpress.httpstheredefiningproductions.phonefinder.recorder.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    //initialize the thing that will keep the service running
    mgr = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
    //turn on the wakelock
    PowerManager.WakeLock wakeLock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
    wakeLock.acquire();//w  ww.  j a v  a  2s.c  o  m
    //start the notification
    startForeground(FOREGROUND_ID, buildForegroundNotification("Phone Finder"));
    try {
        //start the listening
        Message msg = new Message();
        msg.what = MSG_RECOGNIZER_START_LISTENING;
        mServerMessenger.send(msg);
    } catch (RemoteException e) {

    }
    //keep running the service:
    return START_STICKY;
}

From source file:com.mk4droid.IMC_Activities.Fragment_NewIssueB.java

/**
 * Executed after activity is created or after changing tab
 *//*from  w ww . ja  v a2 s. co  m*/
@Override
public void onResume() {
    super.onResume();

    // The new issue coordinates
    LastIssLat = 0;
    LastIssLong = 0;

    progressLoc = ProgressDialog.show(ctx, "", "", true);
    progressLoc.setContentView(R.layout.dialog_transparent_progress);
    ((TextView) progressLoc.findViewById(R.id.tv_prog)).setText("");

    resources = SetResources();

    //---------- Map ------
    gmap = fmap.getMap();

    // Check if we were successful in obtaining the map.
    if (gmap != null) {
        gmap.clear();
        gmap.setOnInfoWindowClickListener(this);

        //------- Create Polygon ----------
        if (poly == null)
            poly = GEO.MakeBorders(gmap, getResources());

        gmap.moveCamera(CameraUpdateFactory.newLatLngZoom(pos, 14));

        gmap.setOnMyLocationChangeListener(new OnMyLocationChangeListener() {
            @Override
            public void onMyLocationChange(Location arg0) {

                if (mMarker == null) {
                    pos = new LatLng(arg0.getLatitude(), arg0.getLongitude());

                    gmap.moveCamera(CameraUpdateFactory.newLatLngZoom(pos, 14)); // Cannot zoom to bounds until the map has a size.

                    mMarker = gmap.addMarker(
                            new MarkerOptions().position(pos).title(resources.getString(R.string.Issueposition))
                                    .snippet(resources.getString(R.string.Dragndrop)).draggable(true));

                    Message msg = new Message();
                    msg.arg1 = 1;
                    handlerAddresUPD.sendMessage(msg);
                }
            }
        });

        gmap.setOnMarkerDragListener(this);
        gmap.setMyLocationEnabled(true);

        //----- Timed Trigger to ensure that if loc not found then get prefined loc ---
        new Thread(new Runnable() {

            @Override
            public void run() {

                try {
                    Thread.sleep(6000);

                    if (progressLoc.isShowing()) {
                        Message msg = new Message();
                        msg.arg1 = 2;
                        handlerAddresUPD.sendMessage(msg);
                    }

                } catch (InterruptedException e) {
                }

            }
        }).start();

    }

    // ============ SUBMIT BUTTON ====================
    btSubmit = (Button) vframeLayout_nib.findViewById(R.id.btReport_new_issue);

    btSubmit.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            String titleData_STR = Fragment_NewIssueA.et_title.getText().toString(); // 1. Title Data
            String descriptionData_STR = Fragment_NewIssueA.et_descr.getText().toString(); // 3. Description Data
            Address_STR = etAddress.getText().toString();

            String ImageFN_target = "";

            // Check if Image is taken else do not sent  
            if (Fragment_NewIssueA.flagPictureTaken) {
                String FileNameExt = new SimpleDateFormat("yyyy-MM-dd hh-mm-ss'.jpg'").format(new Date());

                FileNameExt = FileNameExt.replace("-", "_");
                FileNameExt = FileNameExt.replace(" ", "t");
                ImageFN_target = UserID_STR + "d" + FileNameExt;
            }

            double Lat_D = mMarker.getPosition().latitude;
            double Long_D = mMarker.getPosition().longitude;

            // Check if title is long enough and sent
            if (Fragment_NewIssueA.et_title.getText().toString().length() > 2
                    && etAddress.getText().toString().length() > 0
                    && Fragment_NewIssueA.et_descr.getText().toString().length() > 2) {

                if (GEO.insidePoly(poly, Long_D, Lat_D)) {
                    new AsynchTask_ReportIssue(ImageFN_target, titleData_STR, IndexCatSpinner, Lat_D, Long_D,
                            descriptionData_STR, Address_STR, UserNameSTR, PasswordSTR).execute();
                } else {
                    Toast.makeText(ctx, resources.getString(R.string.Issueoutofmunicipalitylimits), tlv).show();
                }
            } else if (Fragment_NewIssueA.et_title.getText().toString().length() <= 2) {
                Toast.makeText(ctx, resources.getString(R.string.LongerTitle), tlv).show();
            } else if (etAddress.getText().toString().length() == 0) {
                Toast.makeText(ctx, resources.getString(R.string.WriteAddress), tlv).show();
            } else if (Fragment_NewIssueA.et_descr.getText().toString().length() <= 2) {
                Toast.makeText(ctx, resources.getString(R.string.LongerDescription), tlv).show();
            }

        }
    });

    //----------- Flurry Analytics --------
    boolean AnalyticsSW = mshPrefs.getBoolean("AnalyticsSW", true);
    if (AnalyticsSW)
        FlurryAgent.onStartSession(ctx, Constants_API.Flurry_Key);
}