Example usage for android.os Message obtain

List of usage examples for android.os Message obtain

Introduction

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

Prototype

public static Message obtain(Handler h, int what) 

Source Link

Document

Same as #obtain() , but sets the values for both target and what members on the Message.

Usage

From source file:com.mediatek.systemupdate.HttpManager.java

private void notifySysoper(int actionType) {
    try {/*  w w w . j  a va2 s . c o  m*/
        switch (actionType) {

        case MSG_DELETE_COMMANDFILE:
            Message msg = Message.obtain(null, MSG_DELETE_COMMANDFILE);
            msg.replyTo = mMessenger;
            Bundle data = new Bundle();
            if (data == null) {
                return;
            }
            data.putString(CMD_FILE_KEY, COMMAND_FILE);
            msg.setData(data);
            if (mService != null) {
                mService.send(msg);
            }
            break;
        default:
            break;
        }
    } catch (RemoteException e) {
        e.printStackTrace();

    }
}

From source file:com.mibr.android.intelligentreminder.INeedToo.java

public void doGetContactsFromService(int msgRemember) {
    if (mService != null) {
        try {/*from www . j  a  v  a2 s. c om*/
            Message msg = Message.obtain(null, MSG_GETCONTACTS);
            msg.arg1 = msgRemember;
            msg.replyTo = mMessenger;
            mService.send(msg);
        } catch (RemoteException e) {
            // There is nothing special we need to do if the service
            // has crashed.
        }
    }
}

From source file:com.juick.android.MainActivity.java

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
    if (s == null)
        return;/*from w ww .jav a 2s.  co m*/

    if (s.equals("useHttpsForJuickHttpAPI")) {
        JuickHttpAPI.setHttpsEnabled(sp.getBoolean("useHttpsForJuickHttpAPI", false));
    }

    if (s.equals("useXMPP")) {
        toggleXMPP(this);
    }
    if (s.equals("juick_gcm")) {
        toggleJuickGCM(this);
    }
    if (s.equals("enableJAMessaging")) {
        toggleJAMessaging();
    }
    if (s.equals("googlePlusNavigation")) {
        updateActionBarMode();
    }
    if (s.equals("enableBrowserComponent")) {
        ComponentName cn = new ComponentName("com.juickadvanced", "com.juick.android.SimpleBrowser");
        boolean skipDontKillApp = sp.getBoolean("skip_dont_kill_app", false);
        getPackageManager().setComponentEnabledSetting(cn,
                sp.getBoolean(s, false) ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                        : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                skipDontKillApp ? 0 : PackageManager.DONT_KILL_APP);
    }
    boolean censorLevelChanged = false;
    if (s.equals("censor")) {
        censorLevelChanged = true;
        Censor.setCensorshipLevel(Integer.parseInt(sp.getString("censor", "0")));
    }
    boolean dontWatchPreferences = sp.getBoolean("dontWatchPreferences", false);
    if (dontWatchPreferences)
        return;
    if (s.startsWith("msrc")) {
        final DragSortListView navigationList = (DragSortListView) findViewById(R.id.navigation_list);
        if (navigationList.isDragEnabled())
            return; // editing is being done
        final int REFRESHNAV = 0xFE0D;
        if (!handler.hasMessages(REFRESHNAV)) {
            Message msg = Message.obtain(handler, new Runnable() {
                @Override
                public void run() {
                    updateNavigation();
                }
            });
            msg.what = REFRESHNAV;
            handler.sendMessageDelayed(msg, 100);
        }
    }
    boolean invalidateRendering = false;
    if (censorLevelChanged) {
        invalidateRendering = true;
    }
    if (s.startsWith("Colors.")) {
        invalidateRendering = true;
    }
    String[] refreshCauses = new String[] { "messagesFontScale", "showNumbers", "wrapUserpics",
            "showUserpics", };
    for (String refreshCause : refreshCauses) {
        if (refreshCause.equals(s)) {
            if (s.equals("messagesFontScale") && sp.getBoolean("enableScaleByGesture", true))
                continue; // should have been pinch zoom
            invalidateRendering = true;
            break;
        }
    }
    if (invalidateRendering) {
        if (mf != null && mf.listAdapter != null)
            mf.listAdapter.notifyDataSetInvalidated();
    }
    if (s.equals("enableLoginNameWithCrashReport")) {
        if (sp.getBoolean("enableLoginNameWithCrashReport", false)) {
            String juickAccountName = JuickAPIAuthorizer.getJuickAccountName(this);
            if (juickAccountName != null)
                Crashlytics.setString("juick_user", juickAccountName);
        } else {
            Crashlytics.setString("juick_user", "");
        }

    }
}