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.photon.phresco.nativeapp.eshop.activity.PhrescoActivity.java

/**
 * Call the error dialog handler method to open the normal error dialog box
 * with OK and Cancel buttons/*from   w  ww  .j  a  v  a 2 s .co m*/
 */
public void showErrorDialogWithCancel() {
    try {
        PhrescoLogger.info(TAG + " processOnComplete - showErrorDialogHandler :");
        Message msg = new Message();
        Bundle errorMessageBundle = new Bundle();
        errorMessageBundle.putString(errMessage, getString(R.string.http_connect_error_message));
        errorMessageBundle.putBoolean(cancelFlag, true);
        msg.setData(errorMessageBundle);
        msg.what = ERROR_DIALOG_FLAG;
        showErrorDialogHandler.sendMessage(msg);
    } catch (Exception ex) {
        PhrescoLogger.info(TAG + " - showErrorDialogWithCancel  - Exception : " + ex.toString());
        PhrescoLogger.warning(ex);
    }
}

From source file:com.cettco.buycar.dealer.activity.OrderDetailActivity.java

private void submit(String url) {
    System.out.println("url:" + url);
    String cookieStr = null;/*from   w  w  w  . j  av  a 2 s .c  om*/
    String cookieName = null;
    PersistentCookieStore myCookieStore = new PersistentCookieStore(this);
    if (myCookieStore == null) {
        System.out.println("cookie store null");
        return;
    }
    List<Cookie> cookies = myCookieStore.getCookies();
    for (Cookie cookie : cookies) {
        String name = cookie.getName();
        cookieName = name;
        System.out.println(name);
        if (name.equals("_JustBidIt_session")) {
            cookieStr = cookie.getValue();
            System.out.println("value:" + cookieStr);
            break;
        }
    }
    if (cookieStr == null || cookieStr.equals("")) {
        System.out.println("cookie null");
        return;
    }
    //String insurance = 
    String insurance = insurancEditText.getText().toString();
    //String vehicleTax = vechileTaxEditText.getText().toString();
    String purchaseTax = purchaseEditText.getText().toString();
    String licenseFee = licenseFeEditText.getText().toString();
    String miscFee = miscFeEditText.getText().toString();
    String price = priceEditText.getText().toString();
    String description = descriptionEditText.getText().toString();
    if (insurance.equals("") || purchaseTax.equals("") || licenseFee.equals("") || miscFee.equals("")
            || price.equals("")) {
        Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT);
        toast.show();
        return;
    }
    JSONObject bidJson = new JSONObject();
    JSONObject json = new JSONObject();
    try {
        bidJson.put("insurance", insurance);
        //bidJson.put("vehicle_tax", vehicleTax);
        bidJson.put("purchase_tax", purchaseTax);
        bidJson.put("license_fee", licenseFee);
        bidJson.put("misc_fee", miscFee);
        bidJson.put("price", price);
        bidJson.put("description", description);
        json.put("bid", bidJson);
        json.put("_method", "patch");
    } catch (JSONException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    //Gson gson = new Gson();
    StringEntity entity = null;
    try {
        System.out.println("patch:" + json.toString());
        entity = new StringEntity(json.toString());
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    //HttpConnection.getClient().re
    HttpConnection.getClient().addHeader("x-http-method-override", "PATCH");
    HttpConnection.getClient().addHeader("Cookie", cookieName + "=" + cookieStr);
    progressLayout.setVisibility(View.VISIBLE);
    HttpConnection.post(this, url, null, entity, "application/json;charset=utf-8",
            new AsyncHttpResponseHandler() {

                @Override
                public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
                    // TODO Auto-generated method stub
                    progressLayout.setVisibility(View.GONE);
                    System.out.println("fail");
                    Message message = new Message();
                    message.what = 5;
                    mHandler.sendMessage(message);
                }

                @Override
                public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
                    // TODO Auto-generated method stub
                    progressLayout.setVisibility(View.GONE);
                    try {
                        String result = new String(arg2, "UTF-8");
                        System.out.println("order detail result:" + result);
                        // Type listType = new
                        // TypeToken<ArrayList<OrderItemEntity>>() {
                        // }.getType();
                        // list = new Gson().fromJson(result, listType);
                        // //System.out.println("size:"+dealerList.size());
                        Message message = new Message();
                        message.what = 6;
                        mHandler.sendMessage(message);
                    } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

            });
}

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

public void publishgoods(final String shopid, final String pic1, final String pic2, final String pic3,
        final String pic4, final String pic5, final String goodsname, final String description,
        final String type, final String brand, final String artNo, final String standard, final String price,
        final String oprice, final String freight, final String inventory, final String content,
        final String address, final String cpiclist) {
    new Thread() {
        Message msg = new Message();

        @Override/*from   w  ww.  j av  a 2s.  c  om*/
        public void run() {
            String data = "&userid=" + user.getUserId() + "&shopid=" + shopid + "&piclist=" + pic1 + "," + pic2
                    + "," + pic3 + "," + pic4 + "," + pic5 + "&goodsname=" + goodsname + "&type=" + type
                    + "&band=" + brand + "&artno=" + artNo + "&unit=" + standard + "&price=" + price
                    + "&oprice=" + oprice + "&freight=" + freight + "&inventory=" + inventory + "&description="
                    + description + "&address=" + address + "&deliverytype=1" + "&content=" + content
                    + "&cpiclist=" + cpiclist;
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(WebAddress.PUBLISHGOODS, data);
            Log.e("successful", result_data);
            try {
                JSONObject obj = new JSONObject(result_data);
                msg.what = CommunalInterfaces.PUBLISHGOODS;
                msg.obj = obj;
                Log.e("return is", result_data);
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}

From source file:org.jnrain.mobile.accounts.kbs.KBSRegisterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.kbs_register);

    mHandler = new Handler() {
        @Override/*w  ww  .  j  a  v a  2s .c o  m*/
        public void handleMessage(Message msg) {
            loadingDlg = DialogHelper.showProgressDialog(KBSRegisterActivity.this,
                    R.string.check_updates_dlg_title, R.string.please_wait, false, false);
        }
    };

    lastUIDCheckTime = 0;

    initValidationMapping();

    // instance state
    if (savedInstanceState != null) {
        /*
         * editNewUID.onRestoreInstanceState(savedInstanceState
         * .getParcelable("newUID"));
         * editNewEmail.onRestoreInstanceState(savedInstanceState
         * .getParcelable("newEmail"));
         * editNewPassword.onRestoreInstanceState(savedInstanceState
         * .getParcelable("newPass"));
         * editRetypeNewPassword.onRestoreInstanceState
         * (savedInstanceState .getParcelable("repeatPass"));
         * editNewNickname.onRestoreInstanceState(savedInstanceState
         * .getParcelable("newNickname"));
         * editStudID.onRestoreInstanceState(savedInstanceState
         * .getParcelable("studID"));
         * editRealName.onRestoreInstanceState(savedInstanceState
         * .getParcelable("realname"));
         * editPhone.onRestoreInstanceState(savedInstanceState
         * .getParcelable("phone"));
         * editCaptcha.onRestoreInstanceState(savedInstanceState
         * .getParcelable("captcha"));
         */

        // captcha image
        byte[] captchaPNG = savedInstanceState.getByteArray("captchaImage");
        ByteArrayInputStream captchaStream = new ByteArrayInputStream(captchaPNG);
        try {
            Drawable captchaDrawable = BitmapDrawable.createFromStream(captchaStream, "src");
            imageRegCaptcha.setImageDrawable(captchaDrawable);
        } finally {
            try {
                captchaStream.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    // event handlers
    // UID
    editNewUID.addTextChangedListener(new StrippedDownTextWatcher() {
        long lastCheckTime = 0;
        String lastUID;

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // FIXME: use monotonic clock...
            long curtime = System.currentTimeMillis();
            if (curtime - lastCheckTime >= KBSUIConstants.REG_CHECK_UID_INTERVAL_MILLIS) {
                String uid = s.toString();

                // don't check at the first char
                if (uid.length() > 1) {
                    checkUIDAvailability(uid, curtime);
                }

                lastCheckTime = curtime;
                lastUID = uid;

                // schedule a new delayed check
                if (delayedUIDChecker != null) {
                    delayedUIDChecker.cancel();
                    delayedUIDChecker.purge();
                }
                delayedUIDChecker = new Timer();
                delayedUIDChecker.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        final String uid = getUID();

                        if (uid != lastUID) {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    checkUIDAvailability(uid, System.currentTimeMillis());
                                }
                            });

                            lastUID = uid;
                        }
                    }
                }, KBSUIConstants.REG_CHECK_UID_INTERVAL_MILLIS);
            }
        }
    });

    editNewUID.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                // lost focus, force check uid availability
                checkUIDAvailability(getUID(), System.currentTimeMillis());
            } else {
                // inputting, temporarily clear that notice
                updateUIDAvailability(false, 0);
            }
        }
    });

    // E-mail
    editNewEmail.addTextChangedListener(new StrippedDownTextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (TextUtils.isEmpty(s)) {
                updateValidation(editNewEmail, false, true, R.string.reg_email_empty);
                return;
            }

            if (!EMAIL_CHECKER.matcher(s).matches()) {
                updateValidation(editNewEmail, false, true, R.string.reg_email_malformed);
                return;
            }

            updateValidation(editNewEmail, true, true, R.string.ok_short);
        }
    });

    // Password
    editNewPassword.addTextChangedListener(new StrippedDownTextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (TextUtils.isEmpty(s)) {
                updateValidation(editNewPassword, false, true, R.string.reg_psw_empty);
                return;
            }

            if (s.length() < 6) {
                updateValidation(editNewPassword, false, true, R.string.reg_psw_too_short);
                return;
            }

            if (s.length() > 39) {
                updateValidation(editNewPassword, false, true, R.string.reg_psw_too_long);
                return;
            }

            if (getUID().equalsIgnoreCase(s.toString())) {
                updateValidation(editNewPassword, false, true, 0);
            }

            updateValidation(editNewPassword, true, true, R.string.ok_short);

            updateRetypedPasswordCorrectness();
        }
    });

    // Retype password
    editRetypeNewPassword.addTextChangedListener(new StrippedDownTextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            updateRetypedPasswordCorrectness();
        }
    });

    // Nickname
    editNewNickname.addTextChangedListener(new StrippedDownTextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (TextUtils.isEmpty(s)) {
                updateValidation(editNewNickname, false, true, R.string.reg_nick_empty);
                return;
            }

            updateValidation(editNewNickname, true, true, R.string.ok_short);
        }
    });

    // Student ID
    editStudID.addTextChangedListener(new StrippedDownTextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (TextUtils.isEmpty(s)) {
                updateValidation(editStudID, false, true, R.string.reg_stud_id_empty);
                return;
            }

            if (!IDENT_CHECKER.matcher(s).matches()) {
                updateValidation(editStudID, false, true, R.string.reg_stud_id_malformed);
                return;
            }

            updateValidation(editStudID, true, true, R.string.ok_short);
        }
    });

    // Real name
    editRealName.addTextChangedListener(new StrippedDownTextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (TextUtils.isEmpty(s)) {
                updateValidation(editRealName, false, true, R.string.reg_realname_empty);
                return;
            }

            updateValidation(editRealName, true, true, R.string.ok_short);
        }
    });

    // Phone
    editPhone.addTextChangedListener(new StrippedDownTextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (TextUtils.isEmpty(s)) {
                updateValidation(editPhone, false, true, R.string.reg_phone_empty);
                return;
            }

            if (!TextUtils.isDigitsOnly(s)) {
                updateValidation(editPhone, false, true, R.string.reg_phone_onlynumbers);
                return;
            }

            updateValidation(editPhone, true, true, R.string.ok_short);
        }
    });

    // Captcha
    editCaptcha.addTextChangedListener(new StrippedDownTextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (TextUtils.isEmpty(s)) {
                updateValidation(editCaptcha, false, true, R.string.reg_captcha_empty);
                return;
            }

            updateValidation(editCaptcha, true, true, R.string.ok_short);
        }
    });

    // Use current phone
    checkUseCurrentPhone.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setUseCurrentPhone(isChecked);
        }
    });

    // Is ethnic minority
    checkIsEthnicMinority.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setEthnicMinority(isChecked);
        }
    });

    // Submit form!
    btnSubmitRegister.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            // progress dialog
            mHandler.sendMessage(new Message());

            // prevent repeated requests
            setSubmitButtonEnabled(false);

            // fire our biiiiiig request!
            // TODO: ??23333
            final String uid = getUID();
            final String psw = editNewPassword.getText().toString();
            makeSpiceRequest(
                    new KBSRegisterRequest(uid, psw, editNewNickname.getText().toString(), getRealName(),
                            editStudID.getText().toString(), editNewEmail.getText().toString(), getPhone(),
                            editCaptcha.getText().toString(), 2),
                    new KBSRegisterRequestListener(KBSRegisterActivity.this, uid, psw));
        }
    });

    // interface init
    // UID availability
    updateUIDAvailability(false, 0);

    // HTML-formatted register disclaimer
    FormatHelper.setHtmlText(this, textRegisterDisclaimer, R.string.register_disclaimer);
    textRegisterDisclaimer.setMovementMethod(LinkMovementMethod.getInstance());

    // is ethnic minority defaults to false
    checkIsEthnicMinority.setChecked(false);
    setEthnicMinority(false);

    // current phone number
    currentPhoneNumber = TelephonyHelper.getPhoneNumber(this);
    isCurrentPhoneNumberAvailable = currentPhoneNumber != null;

    if (isCurrentPhoneNumberAvailable) {
        // display the obtained number as hint
        FormatHelper.setHtmlText(this, checkUseCurrentPhone, R.string.field_use_current_phone,
                currentPhoneNumber);
    } else {
        // phone number unavailable, disable the choice
        checkUseCurrentPhone.setEnabled(false);
        checkUseCurrentPhone.setVisibility(View.GONE);
    }

    // default to use current phone number if available
    checkUseCurrentPhone.setChecked(isCurrentPhoneNumberAvailable);
    setUseCurrentPhone(isCurrentPhoneNumberAvailable);

    if (savedInstanceState == null) {
        // issue preflight request
        // load captcha in success callback
        this.makeSpiceRequest(new KBSRegisterRequest(), new KBSRegisterRequestListener(this));
    }
}

From source file:cm.aptoide.pt.RemoteInSearch.java

private String downloadFile(int position) {
    Vector<DownloadNode> tmp_serv = new Vector<DownloadNode>();
    String getserv = new String();
    String md5hash = null;//from  w  w w .  ja v  a 2s. com
    String repo = null;

    try {
        tmp_serv = db.getPathHash(apk_lst.get(position).apkid);

        if (tmp_serv.size() > 0) {
            DownloadNode node = tmp_serv.get(0);
            getserv = node.repo + "/" + node.path;
            md5hash = node.md5h;
            repo = node.repo;
        }

        if (getserv.length() == 0)
            throw new TimeoutException();

        Message msg = new Message();
        msg.arg1 = 0;
        msg.obj = new String(getserv);
        download_handler.sendMessage(msg);

        /*BufferedInputStream getit = new BufferedInputStream(new URL(getserv).openStream());
                
        String path = new String(APK_PATH+apk_lst.get(position).name+".apk");
                
        FileOutputStream saveit = new FileOutputStream(path);
        BufferedOutputStream bout = new BufferedOutputStream(saveit,1024);
        byte data[] = new byte[1024];
                
        int readed = getit.read(data,0,1024);
        while(readed != -1) {
           bout.write(data,0,readed);
           readed = getit.read(data,0,1024);
        }
        bout.close();
        getit.close();
        saveit.close();*/

        String path = new String(APK_PATH + apk_lst.get(position).name + ".apk");
        FileOutputStream saveit = new FileOutputStream(path);
        DefaultHttpClient mHttpClient = new DefaultHttpClient();
        HttpGet mHttpGet = new HttpGet(getserv);

        String[] logins = null;
        logins = db.getLogin(repo);
        if (logins != null) {
            URL mUrl = new URL(getserv);
            mHttpClient.getCredentialsProvider().setCredentials(new AuthScope(mUrl.getHost(), mUrl.getPort()),
                    new UsernamePasswordCredentials(logins[0], logins[1]));
        }

        HttpResponse mHttpResponse = mHttpClient.execute(mHttpGet);
        if (mHttpResponse.getStatusLine().getStatusCode() == 401) {
            return null;
        } else {
            byte[] buffer = EntityUtils.toByteArray(mHttpResponse.getEntity());
            saveit.write(buffer);
        }

        File f = new File(path);
        Md5Handler hash = new Md5Handler();
        if (md5hash == null || md5hash.equalsIgnoreCase(hash.md5Calc(f))) {
            return path;
        } else {
            return null;
        }
    } catch (Exception e) {
        return null;
    }
}

From source file:com.zoffcc.applications.zanavi.ZANaviMainIntroActivityStatic.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    System.out.println("ZANaviMainIntroActivity:" + "onActivityResult");

    switch (requestCode) {
    case Navit.NavitDeleteSecSelectMap_id:
        try {//  w ww  .j av a 2s .  co m
            if (resultCode == AppCompatActivity.RESULT_OK) {
                System.out.println("Global_Location_update_not_allowed = 1");
                Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!

                // remove all sdcard maps
                Message msg = new Message();
                Bundle b = new Bundle();
                b.putInt("Callback", 19);
                msg.setData(b);
                NavitGraphics.callback_handler.sendMessage(msg);

                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                }

                Log.d("Navit", "delete map id=" + Integer.parseInt(data.getStringExtra("selected_id")));
                String map_full_line = NavitMapDownloader.OSM_MAP_NAME_ondisk_ORIG_LIST[Integer
                        .parseInt(data.getStringExtra("selected_id"))];
                Log.d("Navit", "delete map full line=" + map_full_line);

                String del_map_name = Navit.MAP_FILENAME_PATH + map_full_line.split(":", 2)[0];
                System.out.println("del map file :" + del_map_name);
                // remove from cat file
                NavitMapDownloader.remove_from_cat_file(map_full_line);
                // remove from disk
                File del_map_name_file = new File(del_map_name);
                del_map_name_file.delete();
                for (int jkl = 1; jkl < 51; jkl++) {
                    File del_map_name_fileSplit = new File(del_map_name + "." + String.valueOf(jkl));
                    del_map_name_fileSplit.delete();
                }
                // also remove index file
                File del_map_name_file_idx = new File(del_map_name + ".idx");
                del_map_name_file_idx.delete();
                // remove also any MD5 files for this map that may be on disk
                try {
                    String tmp = map_full_line.split(":", 2)[1];
                    if (!tmp.equals(NavitMapDownloader.MAP_URL_NAME_UNKNOWN)) {
                        tmp = tmp.replace("*", "");
                        tmp = tmp.replace("/", "");
                        tmp = tmp.replace("\\", "");
                        tmp = tmp.replace(" ", "");
                        tmp = tmp.replace(">", "");
                        tmp = tmp.replace("<", "");
                        System.out.println("removing md5 file:" + Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
                        File md5_final_filename = new File(Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
                        md5_final_filename.delete();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }

                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                }

                // add all sdcard maps
                msg = new Message();
                b = new Bundle();
                b.putInt("Callback", 20);
                msg.setData(b);
                NavitGraphics.callback_handler.sendMessage(msg);

                System.out.println("Global_Location_update_not_allowed = 0");
                Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!

                // -----------------
                Navit.intro_flag_indexmissing = false;
                try {
                    // go to next slide
                    btnNext.callOnClick();
                    // -----------------
                } catch (java.lang.NoSuchMethodError e2) {
                    System.out.println("ZANaviMainIntroActivity:" + "callOnClick:Ex01");
                }
            }
        } catch (Exception e) {
            Log.d("Navit", "error on onActivityResult 3");
            e.printStackTrace();
        }
        break;
    }
}

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

private void HandlersAndReceivers() {

    handlerBroadcastListRefresh = new Handler() // Broadcast  2. DistanceCh 3. IssuesNoCh
    {/*from www . ja v a 2  s . co  m*/
        public void handleMessage(Message msg) {
            InitList();
            super.handleMessage(msg);
        }
    };

    // --------- Broadcast that refresh is needed
    handlerBroadcastRefresh = new Handler() // Broadcast  2. DistanceCh 3. IssuesNoCh
    {
        public void handleMessage(Message msg) {
            if (msg.arg1 == 2)
                ctx.sendBroadcast(
                        new Intent("android.intent.action.MAIN").putExtra("DistanceChanged", "Indeed"));
            else if (msg.arg1 == 3)
                ctx.sendBroadcast(new Intent("android.intent.action.MAIN").putExtra("IssuesNoChanged", "yep"));

            super.handleMessage(msg);
        }
    };

    //---------- Upon Data Changed start updating the UI
    intentFilter = new IntentFilter("android.intent.action.MAIN"); // DataCh

    mReceiverDataChanged = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {

            String DataChanged = intent.getStringExtra("DataChanged");

            if (DataChanged != null) {
                handlerBroadcastListRefresh.sendMessage(new Message());
            }
        }
    };

    if (!isReg_mReceiverDataChanged) {
        getActivity().registerReceiver(mReceiverDataChanged, intentFilter);
        isReg_mReceiverDataChanged = true;
    }
}

From source file:com.tonnguyen.livelotte.HomeActivity.java

/**
 * ask thread handler to reload result//from www .j ava 2  s .  c  o m
 */
private void askThreadHandlerToUpdateResult() {
    Message msg = new Message();
    msg.what = 1; // whatever
    threadHandler.sendMessage(msg);
}

From source file:com.jinfukeji.jinyihuiup.indexBannerClick.ZhiboActivity.java

@Override
public void onJoin(int result) {
    String msg = null;/*from ww  w  .j  a v  a  2 s. co m*/
    switch (result) {
    case JOIN_OK:
        msg = "?";
        Message message = new Message();
        message.what = HANDlER.SUCCESSJOIN;
        mHandler.sendMessage(message);
        break;
    case JOIN_CONNECTING:
        msg = "";
        break;
    case JOIN_CONNECT_FAILED:
        msg = "";
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
        break;
    case JOIN_RTMP_FAILED:
        msg = "?";
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
        break;
    case JOIN_TOO_EARLY:
        msg = "";
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
        break;
    case JOIN_LICENSE:
        msg = "";
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
        break;
    default:
        msg = "" + result;
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
        break;
    }
}

From source file:com.poomoo.edao.activity.UploadPicsActivity.java

private void upload(File file) {
    HttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost(eDaoClientConfig.imageurl); // ?Post?,Post
    client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, eDaoClientConfig.timeout);
    client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, eDaoClientConfig.timeout);

    MultipartEntity entity = new MultipartEntity(); // ,
    // List<File> list = new ArrayList<File>();
    // // File// w ww .  j av  a2 s  . com
    // list.add(file1);
    // list.add(file2);
    // list.add(file3);
    // list.add(file4);
    // System.out.println("list.size():" + list.size());
    // for (int i = 0; i < list.size(); i++) {
    // ContentBody body = new FileBody(list.get(i));
    // entity.addPart("file", body); // ???
    // }
    System.out.println(
            "upload" + "uploadCount" + ":" + uploadCount + "filelist.size" + ":" + filelist.size());
    entity.addPart("file", new FileBody(file));

    post.setEntity(entity); // ?Post?
    Message message = new Message();
    try {
        entity.addPart("imageType", new StringBody(String.valueOf(uploadCount + 1), Charset.forName("utf-8")));
        entity.addPart("userId", new StringBody(userId, Charset.forName("utf-8")));
        HttpResponse response;
        response = client.execute(post);
        // Post
        if (response.getStatusLine().getStatusCode() == 200) {
            uploadCount++;
            message.what = 1;
        } else
            message.what = 2;
        // return EntityUtils.toString(response.getEntity(), "UTF-8"); //
        // ??
    } catch (Exception e) {
        // TODO ? catch ?
        e.printStackTrace();
        message.what = 2;
        System.out.println("IOException:" + e.getMessage());
    } finally {
        client.getConnectionManager().shutdown(); // ?
        myHandler.sendMessage(message);
    }
}