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.hartcode.hartweather.list.WeatherListActivity.java

@Override
public void onNetworkQueueChange(boolean isEmpty) {
    Message msg = new Message();
    Bundle bundle = new Bundle();
    bundle.putBoolean(getString(R.string.network_is_empty_key), isEmpty);
    msg.setData(bundle);/*  ww  w  .j av a  2 s.  c o m*/
    msg.what = 0;
    this.networkDataChangeHandler.sendMessage(msg);
}

From source file:com.cleanwiz.applock.ui.activity.SplashActivity.java

public void checkVersion() {
    requestQueue = Volley.newRequestQueue(this);
    String url = "http://www.toolwiz.com/android/checkfiles.php";
    final String oldVersionString = getApplicationVersion();
    Locale locale = getResources().getConfiguration().locale;
    String language = locale.getLanguage();
    Uri.Builder builder = Uri.parse(url).buildUpon();
    builder.appendQueryParameter("uid", AndroidUtil.getUdid(this));
    builder.appendQueryParameter("version", oldVersionString);
    builder.appendQueryParameter("action", "checkfile");
    builder.appendQueryParameter("app", "locklocker");
    builder.appendQueryParameter("language", language);

    jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, builder.toString(), null,
            new Response.Listener<JSONObject>() {

                @SuppressLint("NewApi")
                @Override/*from ww w .  j  a va  2  s .  com*/
                public void onResponse(JSONObject arg0) {
                    // TODO Auto-generated method stub
                    LogUtil.e("colin", "success");
                    if (arg0.has("status")) {
                        try {
                            String status = arg0.getString("status");
                            if (Integer.valueOf(status) == 1) {
                                JSONObject msgJsonObject = arg0.getJSONObject("msg");
                                double version = msgJsonObject.getDouble("version");
                                downLoadFileUrl = msgJsonObject.getString("url");
                                fileSize = msgJsonObject.getString("size");
                                if (Double.valueOf(oldVersionString) < version && !downLoadFileUrl.isEmpty()) {
                                    // ???
                                    String intro = msgJsonObject.getString("intro");
                                    LogUtil.e("colin", "........" + intro);
                                    showUpdateDialog(intro);
                                } else {
                                    LogUtil.e("colin", "check update status is same not to update");
                                    SplashHandler handler = new SplashHandler();
                                    Message msg = new Message();
                                    msg.what = CHECKVERSION_EOOR;
                                    handler.sendMessage(msg);
                                }
                            } else {
                                LogUtil.e("colin", "check update status is error");
                                SplashHandler handler = new SplashHandler();
                                Message msg = new Message();
                                msg.what = CHECKVERSION_EOOR;
                                handler.sendMessage(msg);
                            }
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            SplashHandler handler = new SplashHandler();
                            Message msg = new Message();
                            msg.what = CHECKVERSION_EOOR;
                            handler.sendMessage(msg);
                            e.printStackTrace();
                        }
                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError arg0) {
                    // TODO Auto-generated method stub
                    SplashHandler handler = new SplashHandler();
                    Message msg = new Message();
                    msg.what = CHECKVERSION_EOOR;
                    handler.sendMessage(msg);
                }
            });
    requestQueue.add(jsonObjectRequest);
}

From source file:info.unyttig.helladroid.newzbin.NewzBinController.java

/**
 * Send back a update status message to the message handler.
 * This is used for short messages to the user, like "Search had no result" etc.
 * /*from   w w w .  j  a  va 2  s.  c  o  m*/
 * @param messageHandler
 * @param txt
 */
private static void sendUserMsg(final Handler messageHandler, final String txt) {
    Message msg = new Message();
    msg.setTarget(messageHandler);
    msg.what = MSG_NOTIFY_USER_ERROR;
    msg.obj = txt;
    msg.sendToTarget();
}

From source file:org.kde.kdeconnect.Plugins.MprisPlugin.MprisPlugin.java

public void setPlayer(String player) {
    if (player == null || player.equals(this.player))
        return;//from ww w.j a  v  a  2s.  com
    this.player = player;
    currentSong = "";
    volume = 50;
    playing = false;
    playAllowed = true;
    pauseAllowed = true;
    goNextAllowed = true;
    goPreviousAllowed = true;
    seekAllowed = true;
    for (String key : playerStatusUpdated.keySet()) {
        try {
            playerStatusUpdated.get(key).dispatchMessage(new Message());
        } catch (Exception e) {
            e.printStackTrace();
            Log.e("MprisControl", "Exception");
            playerStatusUpdated.remove(key);
        }
    }
    requestPlayerStatus();
}

From source file:org.jnrain.mobile.ui.MainActivity.java

@SuppressWarnings("unchecked")
public void onAccountAcquired(Account account) {
    Log.d(TAG, "Account info: " + account.toString());

    String psw = AccountManager.get(this).getPassword(account);

    _loginHandler.sendMessage(new Message());
    makeSpiceRequest(new KBSLoginRequest(account.name, psw),
            new KBSLoginRequestListener(this, account, account.name, psw));
}

From source file:com.hartcode.hartweather.list.WeatherListActivity.java

@Override
public void onNetworkError(String error) {
    Message msg = new Message();
    Bundle bundle = new Bundle();
    bundle.putString(getString(R.string.network_error_key), error);
    msg.setData(bundle);//from www.j a  v a  2s  . c o m
    msg.what = 1;
    this.networkDataChangeHandler.sendMessage(msg);
}

From source file:babybear.akbquiz.ConfigActivity.java

/**
 * ?/*from w  ww.  j a v a  2 s. c o  m*/
 */
private void init() {

    ToggleButton bgm_toggle = (ToggleButton) findViewById(R.id.bgm_switch);
    ToggleButton sound_toggle = (ToggleButton) findViewById(R.id.sound_switch);
    ToggleButton vibration_toggle = (ToggleButton) findViewById(R.id.config_vibration_switch);
    SeekBar bgm_vol = (SeekBar) findViewById(R.id.bgm_volume);
    SeekBar sound_vol = (SeekBar) findViewById(R.id.sound_volume);
    Button config_playlist = (Button) findViewById(R.id.config_playlist);

    bgm_toggle.setChecked(sp_cfg.getBoolean(Database.KEY_switch_bg, true));
    sound_toggle.setChecked(sp_cfg.getBoolean(Database.KEY_switch_sound, true));
    vibration_toggle.setChecked(sp_cfg.getBoolean(Database.KEY_switch_vibration, true));
    bgm_vol.setProgress(sp_cfg.getInt(Database.KEY_vol_bg, 10));
    sound_vol.setProgress(sp_cfg.getInt(Database.KEY_vol_sound, 10));

    // ?
    loopmode = sp_cfg.getInt(Database.KEY_bgm_loopmode, BgMusic.MODE_LOOP);
    switch (loopmode) {
    case BgMusic.MODE_LOOP:
        ((Button) findViewById(R.id.config_loopmode)).setText(R.string.config_loop);
    case BgMusic.MODE_RANDOM:
        ((Button) findViewById(R.id.config_loopmode)).setText(R.string.config_random);
    case BgMusic.MODE_SINGLE:
        ((Button) findViewById(R.id.config_loopmode)).setText(R.string.config_single);
    }
    // ?

    if (sp_cfg.getBoolean(Database.KEY_use_custom_background, false)) {
        cfgflipper.setBackgroundDrawable(Drawable.createFromPath(customBgImage.getPath()));
    }

    OnClickListener clickListener = new OnClickListener() {

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.bgm_switch:
                boolean isBgOn = ((ToggleButton) v).isChecked();
                cfgEditor.putBoolean(Database.KEY_switch_bg, isBgOn);
                Message msg = new Message();
                msg.what = isBgOn ? 1 : 0;
                msg.arg1 = BgMusic.BGHandler.SWITCH_CHANGE;
                BgMusic.bgHandler.sendMessage(msg);
                break;
            case R.id.sound_switch:
                boolean isSoundOn = ((ToggleButton) v).isChecked();
                cfgEditor.putBoolean(Database.KEY_switch_sound, isSoundOn);
                MainMenu.se.setSwitch(isSoundOn);
                break;
            case R.id.config_vibration_switch:
                boolean isVibOn = ((ToggleButton) v).isChecked();
                cfgEditor.putBoolean(Database.KEY_switch_vibration, isVibOn);
                break;
            case R.id.config_playlist:
                if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
                    if (!isPlaylistChanged) {
                        loadPlaylistEditor();
                    }

                    cfgflipper.showNext();

                } else {
                    Toast.makeText(ConfigActivity.this, R.string.sdcard_unavailable, Toast.LENGTH_SHORT).show();
                }
                break;
            case R.id.config_ranking:
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("market://details?id=" + getPackageName()));
                startActivity(intent);
                break;

            case R.id.config_back:
                cfgEditor.commit();
                finish();
                break;

            case R.id.config_musiclist_back:
            case R.id.config_playlist_back:
                cfgflipper.showPrevious();
                break;

            case R.id.config_update:
                verCode = getVerCode(ConfigActivity.this);
                verName = getVerName(ConfigActivity.this);
                if (getServerVer()) {
                    if (newVerCode > verCode) {
                        doNewVersionUpdate(); // 
                    } else {
                        notNewVersionShow(); // ???
                    }
                }

                break;
            case R.id.config_loopmode:
                changeLoopMode();
                break;
            case R.id.config_quiz_submit:
                Intent intent1 = new Intent(ConfigActivity.this, CollectQuiz.class);
                startActivity(intent1);
                break;
            case R.id.config_change_bgimage:
                customBgImage();
                break;
            case R.id.config_restore_bgimage:
                restoreBgImage();
                break;
            case R.id.call_calendar_editor:
                Intent calendar = new Intent(ConfigActivity.this, CalendarEditor.class);
                startActivity(calendar);
                break;
            case R.id.who_are_we:
                if (aboutFHS == null) {
                    aboutFHS = (new AlertDialog.Builder(ConfigActivity.this)).setTitle(R.string.who_are_we)
                            .setMessage(R.string.about_fhs).setIcon(R.drawable.fhs_logo_48)
                            .setPositiveButton(android.R.string.ok, null).create();
                }
                aboutFHS.show();
                break;
            case R.id.licence:
                if (license == null) {
                    license = (new AlertDialog.Builder(ConfigActivity.this)).setTitle(R.string.license_title)
                            .setIcon(android.R.drawable.stat_sys_warning).setMessage(R.string.license)
                            .setPositiveButton(android.R.string.ok, null).create();
                }
                license.show();
                break;
            }
        }

    };

    bgm_toggle.setOnClickListener(clickListener);
    sound_toggle.setOnClickListener(clickListener);
    vibration_toggle.setOnClickListener(clickListener);
    config_playlist.setOnClickListener(clickListener);

    ((Button) findViewById(R.id.config_back)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_musiclist_back)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_playlist_back)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_update)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_quiz_submit)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_ranking)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_loopmode)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_change_bgimage)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_restore_bgimage)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.call_calendar_editor)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.who_are_we)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.licence)).setOnClickListener(clickListener);

    OnSeekBarChangeListener l_seekbar = new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
            switch (arg0.getId()) {
            case R.id.bgm_volume:
                cfgEditor.putInt(Database.KEY_vol_bg, arg1);
                Message msg = new Message();
                msg.what = arg1;
                msg.arg1 = BgMusic.BGHandler.VOL_CHANGE;
                BgMusic.bgHandler.sendMessage(msg);
                break;
            case R.id.sound_volume:
                cfgEditor.putInt(Database.KEY_vol_sound, arg1);
                MainMenu.se.setVolume(arg1);
                break;
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar arg0) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar arg0) {

        }

    };
    bgm_vol.setOnSeekBarChangeListener(l_seekbar);
    sound_vol.setOnSeekBarChangeListener(l_seekbar);
}

From source file:org.bwgz.quotation.activity.QuotationActivity.java

private void stopLoadMessage() {
    Bundle bundle = new Bundle();
    bundle.putString(LOAD_STATE, LoadState.LOADED.toString());
    Message message = new Message();
    message.setData(bundle);//w  w w  .j a va2s .c om
    lazyLoadMessageHandler.sendMessage(message);
}

From source file:com.firesoft.member.Activity.F0_ProfileActivity.java

@Override
public void OnMessageResponse(String url, JSONObject jo, AjaxStatus status) throws JSONException {
    // TODO Auto-generated method stub
    if (url.endsWith(ApiInterface.MEMBER_DEL)) {
        memberaddResponse response = new memberaddResponse();
        response.fromJson(jo);// w  ww  .jav  a  2 s .  co  m
        if (response.succeed == 1) {
            /*Intent intent = new Intent(this, C0_ServiceListActivity.class);
            //startActivity(intent);
            setResult(Activity.RESULT_OK, intent);*/
            ToastShow("??");
            finish();
            Message msg = new Message();
            msg.what = MessageConstant.REFRESH_LIST;
            EventBus.getDefault().post(msg);
        } else {
            if (response.error_code == APIErrorCode.NICKNAME_EXIST) {
                member_no.requestFocus();
            }
        }
    } else if (url.endsWith(ApiInterface.MEMBER_UPDATE)) {
        memberaddResponse response = new memberaddResponse();
        response.fromJson(jo);
        if (response.succeed == 1) {
            ToastShow("???");
            finish();
            Message msg = new Message();
            msg.what = MessageConstant.REFRESH_LIST;
            EventBus.getDefault().post(msg);
        } else {
            if (response.error_code == APIErrorCode.NICKNAME_EXIST) {
                member_name.requestFocus();
            }
        }
    }
}

From source file:com.tinyhydra.botd.BotdServerOperations.java

public static void GetTopTen(final Activity activity, final Handler handler, boolean override) {
    final SharedPreferences settings = activity.getSharedPreferences(Const.GenPrefs, 0);
    final List<JavaShop> TopTen = new ArrayList<JavaShop>();
    for (int i = 0; i < 10; i++) {
        TopTen.add(new JavaShop());
    }//from w  w w  .j av  a  2s  . com
    if (settings.getLong(Const.LastTopTenQueryTime, 0) > (Calendar.getInstance().getTimeInMillis() - 180000)
            & !override) {
        Message msg = new Message();
        msg.arg1 = Const.CODE_GETTOPTEN;
        handler.sendMessage(msg);
    } else
        new Thread() {
            @Override
            public void run() {
                BufferedReader in = null;
                try {
                    HttpClient client = new DefaultHttpClient();
                    HttpGet request = new HttpGet();
                    request.setURI(new URI(activity.getResources().getString(R.string.server_url)));
                    HttpResponse response = client.execute(request);
                    in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                    StringBuffer sb = new StringBuffer("");
                    String line = "";
                    while ((line = in.readLine()) != null) {
                        sb.append(line);
                    }
                    in.close();
                    SharedPreferences.Editor editor = settings.edit();
                    editor.putString(Const.LastTopTenQueryResults, sb.toString());
                    editor.putLong(Const.LastTopTenQueryTime, Calendar.getInstance().getTimeInMillis());
                    editor.commit();

                    Message msg = new Message();
                    msg.arg1 = Const.CODE_GETTOPTEN;
                    handler.sendMessage(msg);

                    // more generic error handling
                    //TODO: implement better error handling
                } catch (URISyntaxException usex) {
                    usex.printStackTrace();
                    Utils.PostToastMessageToHandler(handler,
                            "Unable to retrieve Brew of the day. Poor signal? Please try again",
                            Toast.LENGTH_LONG);
                } catch (ClientProtocolException cpex) {
                    cpex.printStackTrace();
                    Utils.PostToastMessageToHandler(handler,
                            "Unable to retrieve Brew of the day. Poor signal? Please try again",
                            Toast.LENGTH_LONG);
                } catch (IOException iex) {
                    iex.printStackTrace();
                    Utils.PostToastMessageToHandler(handler,
                            "Unable to retrieve Brew of the day. Poor signal? Please try again",
                            Toast.LENGTH_LONG);
                } finally {
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }.start();
}