Example usage for android.os Bundle getParcelable

List of usage examples for android.os Bundle getParcelable

Introduction

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

Prototype

@Nullable
public <T extends Parcelable> T getParcelable(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java

/**
 * Called when the activity starts up. Do activity initialization
 * here, not in a constructor./*from  w  w  w .  j a v  a2  s. c om*/
 * 
 * @see Activity#onCreate
 */
@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    CookieSyncManager.createInstance(getApplicationContext());

    mSettings.loadRedditPreferences(this, mClient);

    setRequestedOrientation(mSettings.getRotation());
    setTheme(mSettings.getTheme());
    requestWindowFeature(Window.FEATURE_PROGRESS);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.comments_list_content);
    registerForContextMenu(getListView());

    if (savedInstanceState != null) {
        mReplyTargetName = savedInstanceState.getString(Constants.REPLY_TARGET_NAME_KEY);
        mReportTargetName = savedInstanceState.getString(Constants.REPORT_TARGET_NAME_KEY);
        mEditTargetBody = savedInstanceState.getString(Constants.EDIT_TARGET_BODY_KEY);
        mDeleteTargetKind = savedInstanceState.getString(Constants.DELETE_TARGET_KIND_KEY);
        mThreadTitle = savedInstanceState.getString(Constants.THREAD_TITLE_KEY);
        mSubreddit = savedInstanceState.getString(Constants.SUBREDDIT_KEY);
        mThreadId = savedInstanceState.getString(Constants.THREAD_ID_KEY);
        mVoteTargetThing = savedInstanceState.getParcelable(Constants.VOTE_TARGET_THING_INFO_KEY);

        if (mThreadTitle != null) {
            setTitle(mThreadTitle + " : " + mSubreddit);
        }

        mCommentsList = (ArrayList<ThingInfo>) getLastNonConfigurationInstance();
        if (mCommentsList == null) {
            getNewDownloadCommentsTask().execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT);
        } else {
            // Orientation change. Use prior instance.
            resetUI(new CommentsListAdapter(this, mCommentsList));
        }
    }

    // No saved state; use info from Intent.getData()
    else {
        String commentPath;
        String commentQuery;
        String jumpToCommentId = null;
        int jumpToCommentContext = 0;
        // We get the URL through getIntent().getData()
        Uri data = getIntent().getData();
        if (data != null) {
            // Comment path: a URL pointing to a thread or a comment in a thread.
            commentPath = data.getPath();
            commentQuery = data.getQuery();
        } else {
            if (Constants.LOGGING)
                Log.e(TAG, "Quitting because no subreddit and thread id data was passed into the Intent.");
            finish();
            return;
        }

        if (commentPath != null) {
            if (Constants.LOGGING)
                Log.d(TAG, "comment path: " + commentPath);

            if (Util.isRedditShortenedUri(data)) {
                // http://redd.it/abc12
                mThreadId = commentPath.substring(1);
            } else {
                // http://www.reddit.com/...
                Matcher m = COMMENT_PATH_PATTERN.matcher(commentPath);
                if (m.matches()) {
                    mSubreddit = m.group(1);
                    mThreadId = m.group(2);
                    jumpToCommentId = m.group(3);
                }
            }
        } else {
            if (Constants.LOGGING)
                Log.e(TAG, "Quitting because of bad comment path.");
            finish();
            return;
        }

        if (commentQuery != null) {
            Matcher m = COMMENT_CONTEXT_PATTERN.matcher(commentQuery);
            if (m.find()) {
                jumpToCommentContext = m.group(1) != null ? Integer.valueOf(m.group(1)) : 0;
            }
        }

        // Extras: subreddit, threadTitle, numComments
        // subreddit is not always redundant to Intent.getData(),
        // since URL does not always contain the subreddit. (e.g., self posts)
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            // subreddit could have already been set from the Intent.getData. don't overwrite with null here!
            String subreddit = extras.getString(Constants.EXTRA_SUBREDDIT);
            if (subreddit != null)
                mSubreddit = subreddit;
            // mThreadTitle has not been set yet, so no need for null check before setting it
            mThreadTitle = extras.getString(Constants.EXTRA_TITLE);
            if (mThreadTitle != null) {
                setTitle(mThreadTitle + " : " + mSubreddit);
            }
            // TODO: use extras.getInt(Constants.EXTRA_NUM_COMMENTS) somehow
        }

        if (!StringUtils.isEmpty(jumpToCommentId)) {
            getNewDownloadCommentsTask().prepareLoadAndJumpToComment(jumpToCommentId, jumpToCommentContext)
                    .execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT);
        } else {
            getNewDownloadCommentsTask().execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT);
        }
    }
}

From source file:com.adkdevelopment.earthquakesurvival.ui.DetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.detailed_fragment, container, false);
    setHasOptionsMenu(true);//from w w  w. j ava 2  s . co  m

    mUnbinder = ButterKnife.bind(this, rootView);

    if (getActivity().getIntent().hasExtra(Feature.GEOFENCE)) {

        ArrayList<String> place = getActivity().getIntent().getStringArrayListExtra(Feature.GEOFENCE);

        Cursor cursor = null;
        if (place != null && place.size() > 1) {
            cursor = getActivity().getContentResolver().query(EarthquakeColumns.CONTENT_URI, null,
                    EarthquakeColumns.URL + "= ?", new String[] { place.get(1) }, null);
        }

        if (cursor != null && cursor.getCount() > 0) {
            cursor.moveToFirst();

            long dateMillis = cursor.getLong(cursor.getColumnIndex(EarthquakeColumns.TIME));
            double latitude = cursor.getDouble(cursor.getColumnIndex(EarthquakeColumns.LATITUDE));
            double longitude = cursor.getDouble(cursor.getColumnIndex(EarthquakeColumns.LONGITUDE));

            LatLng latLng = new LatLng(latitude, longitude);

            mCameraPosition = CameraPosition.builder().target(latLng).zoom(LocationUtils.CAMERA_DEFAULT_ZOOM)
                    .build();

            mDistance = getString(R.string.earthquake_distance,
                    LocationUtils.getDistance(latLng, LocationUtils.getLocation(getContext())));
            mDate = Utilities.getRelativeDate(dateMillis);
            mDescription = Utilities
                    .formatEarthquakePlace(cursor.getString(cursor.getColumnIndex(EarthquakeColumns.PLACE)));
            mLink = cursor.getString(cursor.getColumnIndex(EarthquakeColumns.URL));
            mMagnitude = cursor.getDouble(cursor.getColumnIndex(EarthquakeColumns.MAG));
            mDepth = cursor.getDouble(cursor.getColumnIndex(EarthquakeColumns.DEPTH)) / 1.6;
            cursor.close();

            setDataToViews();
        }

    } else if (getActivity().getIntent() != null) {
        Intent input = getActivity().getIntent();
        mDate = input.getStringExtra(Feature.DATE);
        mDescription = input.getStringExtra(Feature.PLACE);
        mLink = input.getStringExtra(Feature.LINK);
        mMagnitude = input.getDoubleExtra(Feature.MAGNITUDE, 0.0);
        mPosition = input.getParcelableExtra(Feature.LATLNG);
        mDistance = input.getStringExtra(Feature.DISTANCE);
        mDepth = input.getDoubleExtra(Feature.DEPTH, 0.0);

        setDataToViews();
    }

    if (mPosition == null) {
        mPosition = LocationUtils.getLocation(getContext());
    }

    final Bundle mapViewSavedInstanceState = savedInstanceState != null
            ? savedInstanceState.getBundle(MAP_STATE)
            : null;

    if (Utilities.checkPlayServices(getActivity())) {
        mMapView.onCreate(mapViewSavedInstanceState);
        mMapView.getMapAsync(this);
    }

    if (savedInstanceState != null) {
        mCameraPosition = savedInstanceState.getParcelable(CAMERA_POSITION);
    } else {
        mCameraPosition = CameraPosition.builder().target(mPosition).zoom(LocationUtils.CAMERA_DEFAULT_ZOOM)
                .build();
    }

    return rootView;
}

From source file:cn.edu.zafu.corepage.base.BaseActivity.java

/**
 * ???/*from w ww .ja va  2 s . c o m*/
 *
 * @param savedInstanceState Bundle
 */
private void loadActivitySavedData(Bundle savedInstanceState) {
    Field[] fields = this.getClass().getDeclaredFields();
    Field.setAccessible(fields, true);
    Annotation[] ans;
    for (Field f : fields) {
        ans = f.getDeclaredAnnotations();
        for (Annotation an : ans) {
            if (an instanceof SaveWithActivity) {
                try {
                    String fieldName = f.getName();
                    @SuppressWarnings("rawtypes")
                    Class cls = f.getType();
                    if (cls == int.class || cls == Integer.class) {
                        f.setInt(this, savedInstanceState.getInt(fieldName));
                    } else if (String.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getString(fieldName));
                    } else if (Serializable.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getSerializable(fieldName));
                    } else if (cls == long.class || cls == Long.class) {
                        f.setLong(this, savedInstanceState.getLong(fieldName));
                    } else if (cls == short.class || cls == Short.class) {
                        f.setShort(this, savedInstanceState.getShort(fieldName));
                    } else if (cls == boolean.class || cls == Boolean.class) {
                        f.setBoolean(this, savedInstanceState.getBoolean(fieldName));
                    } else if (cls == byte.class || cls == Byte.class) {
                        f.setByte(this, savedInstanceState.getByte(fieldName));
                    } else if (cls == char.class || cls == Character.class) {
                        f.setChar(this, savedInstanceState.getChar(fieldName));
                    } else if (CharSequence.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getCharSequence(fieldName));
                    } else if (cls == float.class || cls == Float.class) {
                        f.setFloat(this, savedInstanceState.getFloat(fieldName));
                    } else if (cls == double.class || cls == Double.class) {
                        f.setDouble(this, savedInstanceState.getDouble(fieldName));
                    } else if (String[].class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getStringArray(fieldName));
                    } else if (Parcelable.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getParcelable(fieldName));
                    } else if (Bundle.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getBundle(fieldName));
                    }
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

/**
 * Restores the previous state, if it exists.
 *
 * @param savedState The previous state.
 *//*from   www.  ja  v  a 2  s . c  om*/
@SuppressWarnings("unchecked")
private void restoreState(Bundle savedState) {
    if (savedState == null) {
        return;
    }

    State state = intToState(savedState.getInt(RUNTIME_STATE, State.WORKSPACE.ordinal()));
    if (state == State.APPS_CUSTOMIZE) {
        mOnResumeState = State.APPS_CUSTOMIZE;
    }

    final long pendingAddContainer = savedState.getLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, -1);

    if (pendingAddContainer != ItemInfo.NO_ID) {
        mPendingAddInfo.container = pendingAddContainer;
        mPendingAddInfo.cellX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_X);
        mPendingAddInfo.cellY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_Y);
        mPendingAddInfo.spanX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_X);
        mPendingAddInfo.spanY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y);
        mPendingAddWidgetInfo = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO);
        mPendingAddWidgetId = savedState.getInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID);
        setWaitingForResult(true);
        mRestoring = true;
    }

    // Restore the AppsCustomize tab
    if (mAppsCustomizeTabHost != null) {
        String curTab = savedState.getString("apps_customize_currentTab");
        if (curTab != null) {
            mAppsCustomizeTabHost
                    .setContentTypeImmediate(mAppsCustomizeTabHost.getContentTypeForTabTag(curTab));
            mAppsCustomizeContent.loadAssociatedPages(mAppsCustomizeContent.getCurrentPage());
        }

        int currentIndex = savedState.getInt("apps_customize_currentIndex");
        mAppsCustomizeContent.restorePageForIndex(currentIndex);
    }
}

From source file:com.android.documentsui.DocumentsActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mRoots = DocumentsApplication.getRootsCache(this);

    setResult(Activity.RESULT_CANCELED);
    setContentView(R.layout.activity);//from  w ww.  ja  v a2s  .c  o  m

    final Resources res = getResources();
    mShowAsDialog = res.getBoolean(R.bool.show_as_dialog);

    if (mShowAsDialog) {
        // backgroundDimAmount from theme isn't applied; do it manually
        final WindowManager.LayoutParams a = getWindow().getAttributes();
        a.dimAmount = 0.6f;
        getWindow().setAttributes(a);

        getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
        getWindow().setFlags(~0, WindowManager.LayoutParams.FLAG_DIM_BEHIND);

        // Inset ourselves to look like a dialog
        final Point size = new Point();
        getWindowManager().getDefaultDisplay().getSize(size);

        final int width = (int) res.getFraction(R.dimen.dialog_width, size.x, size.x);
        final int height = (int) res.getFraction(R.dimen.dialog_height, size.y, size.y);
        final int insetX = (size.x - width) / 2;
        final int insetY = (size.y - height) / 2;

        final Drawable before = getWindow().getDecorView().getBackground();
        final Drawable after = new InsetDrawable(before, insetX, insetY, insetX, insetY);
        getWindow().getDecorView().setBackground(after);

        // Dismiss when touch down in the dimmed inset area
        getWindow().getDecorView().setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    final float x = event.getX();
                    final float y = event.getY();
                    if (x < insetX || x > v.getWidth() - insetX || y < insetY || y > v.getHeight() - insetY) {
                        finish();
                        return true;
                    }
                }
                return false;
            }
        });

    } else {
        // Non-dialog means we have a drawer
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_glyph,
                R.string.drawer_open, R.string.drawer_close);

        mDrawerLayout.setDrawerListener(mDrawerListener);
        mDrawerLayout.setDrawerShadow(R.drawable.ic_drawer_shadow, GravityCompat.START);

        mRootsContainer = findViewById(R.id.container_roots);
    }

    mDirectoryContainer = (DirectoryContainerView) findViewById(R.id.container_directory);

    if (icicle != null) {
        mState = icicle.getParcelable(EXTRA_STATE);
    } else {
        buildDefaultState();
    }

    // Hide roots when we're managing a specific root
    if (mState.action == ACTION_MANAGE) {
        if (mShowAsDialog) {
            findViewById(R.id.dialog_roots).setVisibility(View.GONE);
        } else {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        }
    }

    if (mState.action == ACTION_CREATE) {
        final String mimeType = getIntent().getType();
        final String title = getIntent().getStringExtra(Intent.EXTRA_TITLE);
        SaveFragment.show(getFragmentManager(), mimeType, title);
    }

    if (mState.action == ACTION_GET_CONTENT) {
        final Intent moreApps = new Intent(getIntent());
        moreApps.setComponent(null);
        moreApps.setPackage(null);
        RootsFragment.show(getFragmentManager(), moreApps);
    } else if (mState.action == ACTION_OPEN || mState.action == ACTION_CREATE) {
        RootsFragment.show(getFragmentManager(), null);
    }

    if (!mState.restored) {
        if (mState.action == ACTION_MANAGE) {
            final Uri rootUri = getIntent().getData();
            new RestoreRootTask(rootUri).executeOnExecutor(getCurrentExecutor());
        } else {
            new RestoreStackTask().execute();
        }
    } else {
        onCurrentDirectoryChanged(ANIM_NONE);
    }
}

From source file:com.android.mail.compose.ComposeActivity.java

/**
 * Send or Save a message.//from  w  ww .  j a va  2  s . c  om
 */
private void sendOrSaveMessage(SendOrSaveCallback callback, final long messageIdToSave,
        final SendOrSaveMessage sendOrSaveMessage, final ReplyFromAccount selectedAccount) {
    final ContentResolver resolver = getContentResolver();
    final boolean updateExistingMessage = messageIdToSave != UIProvider.INVALID_MESSAGE_ID;

    final String accountMethod = sendOrSaveMessage.mSave ? UIProvider.AccountCallMethods.SAVE_MESSAGE
            : UIProvider.AccountCallMethods.SEND_MESSAGE;

    try {
        if (updateExistingMessage) {
            sendOrSaveMessage.mValues.put(BaseColumns._ID, messageIdToSave);

            callAccountSendSaveMethod(resolver, selectedAccount.account, accountMethod, sendOrSaveMessage);
        } else {
            Uri messageUri = null;
            final Bundle result = callAccountSendSaveMethod(resolver, selectedAccount.account, accountMethod,
                    sendOrSaveMessage);
            if (result != null) {
                // If a non-null value was returned, then the provider handled the call
                // method
                messageUri = result.getParcelable(UIProvider.MessageColumns.URI);
            }
            if (sendOrSaveMessage.mSave && messageUri != null) {
                final Cursor messageCursor = resolver.query(messageUri, UIProvider.MESSAGE_PROJECTION, null,
                        null, null);
                if (messageCursor != null) {
                    try {
                        if (messageCursor.moveToFirst()) {
                            // Broadcast notification that a new message has
                            // been allocated
                            callback.notifyMessageIdAllocated(sendOrSaveMessage, new Message(messageCursor));
                        }
                    } finally {
                        messageCursor.close();
                    }
                }
            }
        }
    } finally {
        // Close any opened file descriptors
        closeOpenedAttachmentFds(sendOrSaveMessage);
    }
}

From source file:com.chen.mail.ui.AbstractActivityController.java

/**
 * Restore the state from the previous bundle. Subclasses should call this
 * method from the parent class, since it performs important UI
 * initialization./*from w w  w . j a v a2s  .c o  m*/
 *
 * @param savedState previous state
 */
@Override
public void onRestoreInstanceState(Bundle savedState) {
    mDetachedConvUri = savedState.getParcelable(SAVED_DETACHED_CONV_URI);
    if (savedState.containsKey(SAVED_CONVERSATION)) {
        // Open the conversation.
        final Conversation conversation = savedState.getParcelable(SAVED_CONVERSATION);
        if (conversation != null && conversation.position < 0) {
            // Set the position to 0 on this conversation, as we don't know where it is
            // in the list
            conversation.position = 0;
        }
        showConversation(conversation);
    }

    if (savedState.containsKey(SAVED_TOAST_BAR_OP)) {
        ToastBarOperation op = savedState.getParcelable(SAVED_TOAST_BAR_OP);
        if (op != null) {
            if (op.getType() == ToastBarOperation.UNDO) {
                onUndoAvailable(op);
            } else if (op.getType() == ToastBarOperation.ERROR) {
                onError(mFolder, true);
            }
        }
    }
    mFolderListFolder = savedState.getParcelable(SAVED_HIERARCHICAL_FOLDER);
    final ConversationListFragment convListFragment = getConversationListFragment();
    if (convListFragment != null) {
        convListFragment.getAnimatedAdapter().onRestoreInstanceState(savedState);
    }
    /*
     * Restore the state of selected conversations. This needs to be done after the correct mode
     * is set and the action bar is fully initialized. If not, several key pieces of state
     * information will be missing, and the split views may not be initialized correctly.
     */
    restoreSelectedConversations(savedState);
    // Order is important!!!
    // The dialog listener needs to happen *after* the selected set is restored.

    // If there has been an orientation change, and we need to recreate the listener for the
    // confirm dialog fragment (delete/archive/...), then do it here.
    if (mDialogAction != -1) {
        makeDialogListener(mDialogAction, mDialogFromSelectedSet);
    }

    mInbox = savedState.getParcelable(SAVED_INBOX_KEY);

    mConversationListScrollPositions.clear();
    mConversationListScrollPositions.putAll(savedState.getBundle(SAVED_CONVERSATION_LIST_SCROLL_POSITIONS));
}

From source file:com.sim2dial.dialer.ChatFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    sipUri = getArguments().getString("SipUri");
    String displayName = getArguments().getString("DisplayName");
    String pictureUri = getArguments().getString("PictureUri");

    view = inflater.inflate(R.layout.chat, container, false);

    contactName = (TextView) view.findViewById(R.id.contactName);
    contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);

    sendMessage = (TextView) view.findViewById(R.id.sendMessage);
    sendMessage.setOnClickListener(this);

    message = (EditText) view.findViewById(R.id.message);
    if (!getActivity().getResources().getBoolean(R.bool.allow_chat_multiline)) {
        message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
        message.setMaxLines(1);/*  w  w w .  j av  a  2  s .c  o  m*/
    }

    uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout);
    textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout);

    messagesLayout = (RelativeLayout) view.findViewById(R.id.messages);
    messagesScrollView = (ScrollView) view.findViewById(R.id.chatScrollView);
    progressBar = (ProgressBar) view.findViewById(R.id.progressbar);

    sendImage = (TextView) view.findViewById(R.id.sendPicture);
    registerForContextMenu(sendImage);
    sendImage.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pickImage();
        }
    });

    cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload);
    cancelUpload.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            uploadThread.interrupt();
            uploadLayout.setVisibility(View.GONE);
            textLayout.setVisibility(View.VISIBLE);
            progressBar.setProgress(0);
        }
    });

    displayChat(displayName, pictureUri);

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
        chatRoom = lc.createChatRoom(sipUri);
    }

    uploadServerUri = Engine.getPref().getString(getString(R.string.pref_image_sharing_server_key),
            getString(R.string.pref_image_sharing_server_default));

    textWatcher = new TextWatcher() {
        public void afterTextChanged(Editable arg0) {

        }

        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }

        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            if (message.getText().toString().equals("")) {
                sendMessage.setEnabled(false);
            } else {
                sendMessage.setEnabled(true);
            }
        }
    };

    // Force hide keyboard
    if (LinphoneActivity.isInstanciated()) {
        InputMethodManager imm = (InputMethodManager) LinphoneActivity.instance()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    // Workaround for SGS3 issue
    if (savedInstanceState != null) {
        fileToUploadPath = savedInstanceState.getString("fileToUploadPath");
        imageToUpload = savedInstanceState.getParcelable("imageToUpload");
    }
    if (fileToUploadPath != null || imageToUpload != null) {
        sendImage.post(new Runnable() {
            @Override
            public void run() {
                sendImage.showContextMenu();
            }
        });
    }

    return view;
}

From source file:com.chen.mail.ui.AbstractActivityController.java

/**
 * Copy any selected conversations stored in the saved bundle into our selection set,
 * triggering {@link ConversationSetObserver} callbacks as our selection set changes.
 *
 *///w w w .j  a v a  2 s.c om
private void restoreSelectedConversations(Bundle savedState) {
    if (savedState == null) {
        mSelectedSet.clear();
        return;
    }
    final ConversationSelectionSet selectedSet = savedState.getParcelable(SAVED_SELECTED_SET);
    if (selectedSet == null || selectedSet.isEmpty()) {
        mSelectedSet.clear();
        return;
    }

    // putAll will take care of calling our registered onSetPopulated method
    mSelectedSet.putAll(selectedSet);
}