Example usage for android.os Bundle getBundle

List of usage examples for android.os Bundle getBundle

Introduction

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

Prototype

@Nullable
public Bundle getBundle(@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.example.jonas.materialmockups.activities.ExhibitDetailsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from w  ww  . j av a  2  s . com*/

    // generated
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    // select first menu item on startup
    navigationView.getMenu().getItem(0).setChecked(true);

    if (savedInstanceState != null) {
        // activity re-creation because of device rotation, instant run, ...

        exhibitPages = (List<Page>) savedInstanceState.getSerializable(KEY_EXHIBIT_PAGES);
        currentPageIndex = savedInstanceState.getInt(KEY_CURRENT_PAGE_INDEX, 0);
        isAudioPlaying = savedInstanceState.getBoolean(KEY_AUDIO_PLAYING, false);
        isAudioToolbarHidden = true;
        extras = savedInstanceState.getBundle(KEY_EXTRAS);

        if (exhibitPages == null)
            throw new NullPointerException("exhibitPages cannot be null!");

    } else {
        // activity creation because of intent
        Intent intent = getIntent();
        extras = intent.getExtras();
        // TODO: extract pages from exhibit contained in intent instead of subsequent init
        exhibitPages.add(new Page(ExhibitPageFragment.Type.APPETIZER));
        for (int noOfPages = 3; noOfPages > 0; noOfPages--)
            exhibitPages.add(new Page(ExhibitPageFragment.Type.IMAGE));
    }

    // set up bottom sheet behavior
    bottomSheet = findViewById(R.id.bottom_sheet);
    bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
    bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            if (fabAction != BottomSheetConfig.FabAction.NEXT) {
                if (newState == BottomSheetBehavior.STATE_EXPANDED)
                    setFabCollapseAction();
                else if (newState == BottomSheetBehavior.STATE_COLLAPSED)
                    setFabExpandAction();
                else {
                    /* we don't care about any other state */}
            }
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
            // intentionally left blank
        }
    });

    // audio toolbar
    mRevealView = (LinearLayout) findViewById(R.id.reveal_items);
    mRevealView.setVisibility(View.INVISIBLE);

    // display audio toolbar on savedInstanceState:
    // if (! isAudioToolbarHidden) showAudioToolbar();
    // does not work because activity creation has not been completed?!

    // set up play / pause toggle
    btnPlayPause = (ImageButton) findViewById(R.id.btnPlayPause);
    btnPlayPause.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            togglePlayPause();
        }
    });

    btnPreviousPage = (ImageButton) findViewById(R.id.buttonPrevious);
    btnPreviousPage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            displayPreviousExhibitPage();
        }
    });

    btnNextPage = (ImageButton) findViewById(R.id.buttonNext);
    btnNextPage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            displayNextExhibitPage();
        }
    });

    fab = (FloatingActionButton) findViewById(R.id.fab);

    displayCurrentExhibitPage();

}

From source file:com.github.nicktgn.mvp.MvpFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    logger.d("onActivityCreated");
    presenter = createPresenter();//  w  w  w. j  a  v  a2 s .c  o m

    // ---- INPUT ARGUMENTS ---- //
    if (argumentsData != null) {
        try {
            // first try to get input model data from fragment arguments
            // NOTE: you can still skip this convenience mechanism, and inject the data into presenter
            // through presenter's constructor for example

            Bundle bundle = getArguments().getBundle(Constants.ARGUMENTS_DATA);
            if (bundle != null) {
                argumentsData = new MvpBundle(bundle);
                logger.d("Got arguments data from fragment arguments");
            }

            // if noting found in arguments, try to get input model data from Intent
            // (that started Activity hosting this Fragment)
            // NOTE: you can still skip this convenience mechanism, and inject the data into presenter
            // through presenter's constructor for example
            else {
                bundle = getActivity().getIntent().getExtras().getBundle(Constants.ARGUMENTS_DATA);
                if (bundle != null) {
                    argumentsData = new MvpBundle(bundle);
                    logger.d("Got argumnets data from intent");
                }
            }
        } catch (NullPointerException e) {
            logger.d("No arguments data");
        }
    }

    // ---- CACHING ---- //
    // if we have savedInstanceState (activity was re-created)
    if (savedInstanceState != null) {
        Bundle bundle = savedInstanceState.getBundle(Constants.CACHED_STATE_DATA);
        if (bundle != null) {
            stateData = new MvpBundle(bundle);
            logger.d("Got cached state data from instance state");
        }
    }
    // else this fragment is just created or came back from back stack
    // try to restore presenter state from MvpState (cause fragment instance is still
    // the same and only the view was re-created)
    else {
        stateData = MvpState.restoreState(this);
        if (stateData != null) {
            logger.d("Got cached data from mvp fragment state");
        }
    }

    presenter.attachView(this, argumentsData, stateData);
}

From source file:de.sourcestream.movieDB.controller.CastDetails.java

/**
 * Called to do initial creation of a fragment.
 * This is called after onAttach(Activity) and before onCreateView(LayoutInflater, ViewGroup, Bundle).
 *
 * @param savedInstanceState If the fragment is being re-created from a previous saved state, this is the state.
 *///w  ww .jav  a  2  s  .co m
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null)
        save = savedInstanceState.getBundle("save");

}

From source file:odoo.controls.SearchableItemActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.base_control_searchable_layout);
    setResult(RESULT_CANCELED);/*w w w .j av a2 s  .c  o  m*/
    edt_searchable_input = (EditText) findViewById(R.id.edt_searchable_input);
    edt_searchable_input.addTextChangedListener(this);
    Bundle extra = getIntent().getExtras();
    if (extra != null) {
        if (extra.containsKey("resource_id")) {
            resource_array_id = extra.getInt("resource_id");
        }
        if (extra.containsKey(OColumn.ROW_ID)) {
            mRowId = extra.getInt(OColumn.ROW_ID);
        }
        if (extra.containsKey("model")) {
            mModel = OModel.get(this, extra.getString("model"), null);
        }
        if (extra.containsKey("live_search")) {
            mLiveSearch = extra.getBoolean("live_search");
        }
        if (extra.containsKey("selected_position")) {
            selected_position = extra.getInt("selected_position");
        }
        if (extra.containsKey("search_hint")) {
            edt_searchable_input.setHint("Search " + extra.getString("search_hint"));
        }
        if (resource_array_id != -1) {
            String[] arrays = getResources().getStringArray(resource_array_id);
            for (int i = 0; i < arrays.length; i++) {
                ODataRow row = new ODataRow();
                row.put(OColumn.ROW_ID, i);
                row.put(mRelModel.getDefaultNameColumn(), arrays[i]);
                objects.add(row);
            }
        } else {
            if (extra.containsKey("column_name")) {
                OColumn mCol = mModel.getColumn(extra.getString("column_name"));
                mRelModel = mModel.createInstance(mCol.getType());

                if (mCol.hasDomainFilterColumn()) {
                    formData = extra.getBundle("form_data");
                    liveDomain = mCol.getDomainFilterParser(mModel).getRPCDomain(formData);
                }
                objects.addAll(OSelectionField.getRecordItems(mRelModel, mCol, formData));
            }
        }

        mList = (ListView) findViewById(R.id.searchable_items);
        mList.setOnItemClickListener(this);
        mAdapter = new OListAdapter(this, android.R.layout.simple_expandable_list_item_1, objects) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View v = convertView;
                if (v == null)
                    v = getLayoutInflater().inflate(getResource(), parent, false);
                ODataRow row = (ODataRow) objects.get(position);
                OControls.setText(v, android.R.id.text1, row.getString(mRelModel.getDefaultNameColumn()));
                if (row.contains(OColumn.ROW_ID) && selected_position == row.getInt(OColumn.ROW_ID)) {
                    v.setBackgroundColor(getResources().getColor(R.color.control_pressed));
                } else {
                    v.setBackgroundColor(Color.TRANSPARENT);
                }
                return v;
            }
        };
        if (mLiveSearch) {
            mAdapter.setOnSearchChange(this);
        }
        mList.setAdapter(mAdapter);
    } else {
        finish();
    }
}

From source file:androidx.media.MediaController2.java

void onConnectedNotLocked(Bundle data) {
    // is enough or should we pass it while connecting?
    final SessionCommandGroup2 allowedCommands = SessionCommandGroup2
            .fromBundle(data.getBundle(ARGUMENT_ALLOWED_COMMANDS));
    final int playerState = data.getInt(ARGUMENT_PLAYER_STATE);
    final int bufferingState = data.getInt(ARGUMENT_BUFFERING_STATE);
    final PlaybackStateCompat playbackStateCompat = data.getParcelable(ARGUMENT_PLAYBACK_STATE_COMPAT);
    final int repeatMode = data.getInt(ARGUMENT_REPEAT_MODE);
    final int shuffleMode = data.getInt(ARGUMENT_SHUFFLE_MODE);
    final List<MediaItem2> playlist = MediaUtils2
            .fromMediaItem2ParcelableArray(data.getParcelableArray(ARGUMENT_PLAYLIST));
    final MediaItem2 currentMediaItem = MediaItem2.fromBundle(data.getBundle(ARGUMENT_MEDIA_ITEM));
    final PlaybackInfo playbackInfo = PlaybackInfo.fromBundle(data.getBundle(ARGUMENT_PLAYBACK_INFO));
    final MediaMetadata2 metadata = MediaMetadata2.fromBundle(data.getBundle(ARGUMENT_PLAYLIST_METADATA));
    if (DEBUG) {/*ww w. j  av a  2s.  c o  m*/
        Log.d(TAG, "onConnectedNotLocked sessionCompatToken=" + mToken.getSessionCompatToken()
                + ", allowedCommands=" + allowedCommands);
    }
    boolean close = false;
    try {
        synchronized (mLock) {
            if (mIsReleased) {
                return;
            }
            if (mConnected) {
                Log.e(TAG, "Cannot be notified about the connection result many times."
                        + " Probably a bug or malicious app.");
                close = true;
                return;
            }
            mAllowedCommands = allowedCommands;
            mPlayerState = playerState;
            mBufferingState = bufferingState;
            mPlaybackStateCompat = playbackStateCompat;
            mRepeatMode = repeatMode;
            mShuffleMode = shuffleMode;
            mPlaylist = playlist;
            mCurrentMediaItem = currentMediaItem;
            mPlaylistMetadata = metadata;
            mConnected = true;
            mPlaybackInfo = playbackInfo;
        }
        mCallbackExecutor.execute(new Runnable() {
            @Override
            public void run() {
                // Note: We may trigger ControllerCallbacks with the initial values
                // But it's hard to define the order of the controller callbacks
                // Only notify about the
                mCallback.onConnected(MediaController2.this, allowedCommands);
            }
        });
    } finally {
        if (close) {
            // Trick to call release() without holding the lock, to prevent potential deadlock
            // with the developer's custom lock within the ControllerCallback.onDisconnected().
            close();
        }
    }
}

From source file:com.google.blockly.android.control.BlocklyController.java

/**
 * Loads a Workspace state from an Android {@link Bundle}, previous saved in
 * {@link #onSaveSnapshot(Bundle)}.//w w w. j a v a  2  s. com
 *
 * @param savedInstanceState The activity state Bundle passed into {@link Activity#onCreate} or
 *     {@link Activity#onRestoreInstanceState}.
 * @return True if a Blockly state was found and successfully loaded into the Controller.
 *     Otherwise, false.
 */
public boolean onRestoreSnapshot(@Nullable Bundle savedInstanceState) {
    Bundle blocklyState = (savedInstanceState == null) ? null
            : savedInstanceState.getBundle(SNAPSHOT_BUNDLE_KEY);
    if (blocklyState != null) {
        byte[] bytes = blocklyState.getByteArray(SERIALIZED_WORKSPACE_KEY);
        if (bytes == null) {
            // Ignore all other workspace variables.
            return false;
        }
        ByteArrayInputStream in = new ByteArrayInputStream(bytes);
        try {
            loadWorkspaceContents(in);
        } catch (BlocklyParserException e) {
            // Ignore all other workspace state variables.
            Log.w(TAG, "Unable to restore Blockly state.", e);
            return false;
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                // Ignore.
            }
        }

        // TODO(#58): Restore the rest of the state.

        return true;
    }
    return false;
}

From source file:com.facebook.Session.java

/**
 * Restores the saved session from a Bundle, if any. Returns the restored Session or
 * null if it could not be restored. This method is intended to be called from an Activity or Fragment's
 * onCreate method when a Session has previously been saved into a Bundle via saveState to preserve a Session
 * across Activity lifecycle events.// ww w . ja v a 2 s.c  om
 *
 * @param context         the Activity or Service creating the Session, must not be null
 * @param cachingStrategy the TokenCachingStrategy to use to load and store the token. If this is
 *                        null, a default token cachingStrategy that stores data in
 *                        SharedPreferences will be used
 * @param callback        the callback to notify for Session state changes, can be null
 * @param bundle          the bundle to restore the Session from
 * @return the restored Session, or null
 */
public static final Session restoreSession(Context context, TokenCachingStrategy cachingStrategy,
        StatusCallback callback, Bundle bundle) {
    if (bundle == null) {
        return null;
    }
    byte[] data = bundle.getByteArray(SESSION_BUNDLE_SAVE_KEY);
    if (data != null) {
        ByteArrayInputStream is = new ByteArrayInputStream(data);
        try {
            Session session = (Session) (new ObjectInputStream(is)).readObject();
            initializeStaticContext(context);
            if (cachingStrategy != null) {
                session.tokenCachingStrategy = cachingStrategy;
            } else {
                session.tokenCachingStrategy = new SharedPreferencesTokenCachingStrategy(context);
            }
            if (callback != null) {
                session.addCallback(callback);
            }
            session.authorizationBundle = bundle.getBundle(AUTH_BUNDLE_SAVE_KEY);
            return session;
        } catch (ClassNotFoundException e) {
            Log.w(TAG, "Unable to restore session", e);
        } catch (IOException e) {
            Log.w(TAG, "Unable to restore session.", e);
        }
    }
    return null;
}

From source file:com.bangz.smartmute.LocationsMapFragment.java

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

    getMapAsync(this);
    mGoogleApiClient = new GoogleApiClient.Builder(getActivity()).addApi(LocationServices.API)
            .addOnConnectionFailedListener(this).addConnectionCallbacks(this).build();

    mGoogleApiClient.connect();//from   w  w w.ja  va2 s . c  om

    if (savedInstanceState == null) {
        mLastLocation = PrefUtils.getLastLatLng(getActivity());
        mapInitState = 0;
    } else {

        // When subclass from MapFragment, do not use outState to save you state data which is
        // parcelable object, if you do, when in onCreate, onCreateView, onActivityCreated ,
        // saveInstance.getParcelable will get Class not found when unmarshalling from
        // java.lang.ClassNotFoundException. The cause may be google play service clean class
        // info in his saveInstance. to workaround this ,you add your all date to a new Bundle
        // and save this Bundle to outState in onSaveInstanceState method.

        // http://stackoverflow.com/a/15973603/1036923
        // in above site, the best answer is suggest use setArguments() when CTO new Bundle,
        // then onSaveInstanceState use getArguments()

        Bundle mybundle = savedInstanceState.getBundle(KEY_STATE_MYARGUMENT);
        mSavedMarkerExInfos = mybundle.getParcelableArrayList(KEY_STATE_MARKERS);
        mapInitState = mybundle.getInt(KEY_STATE_MAPINIT, 0);
        bLocationUpdated = mybundle.getBoolean(KEY_STATE_LOCATION_UPDATED, false);
        mLocationUpdateType = mybundle.getInt(KEY_STATE_LOCATION_UPDATE_TYPE);

        meiSelected = mybundle.getParcelable(KEY_STATE_SELECT_MARKER);
    }
}

From source file:com.jaymullen.TrailJournal.EntryActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Intent intent = getIntent();//w  w w  .  ja  v a 2s.c o m

    String title;
    if (intent.getData() != null) {
        mEntryUri = intent.getData();
        Cursor c = getContentResolver().query(mEntryUri, HomeActivity.Entries.PROJECTION, null, null,
                JournalEntry.DEFAULT_SORT);

        if (c.moveToFirst()) {
            title = c.getString(HomeActivity.Entries.DATE);

            setPostType(c.getString(HomeActivity.Entries.TYPE));

            mIsPublished = c.getInt(HomeActivity.Entries.IS_PUBLISHED) == 1;

            setValuesOnPages(c);
        } else {
            title = "New Entry";
            mIsPublished = false;
        }
        c.close();

    } else {
        title = "New Entry";
        ContentValues cv = new ContentValues();
        cv.put(JournalEntry.JOURNAL_ID, Auth.getInstance(this).getJournalId());
        cv.put(JournalEntry.IS_PUBLISHED, 0);
        mEntryUri = getContentResolver().insert(JournalEntry.CONTENT_URI, cv);
        getIntent().setData(mEntryUri);
        mIsPublished = false;
    }

    getSupportActionBar().setTitle(title);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    if (savedInstanceState != null) {
        mWizardModel.load(savedInstanceState.getBundle("model"));
    }

    mWizardModel.registerListener(this);

    mPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mStepPagerStrip = (StepPagerStrip) findViewById(R.id.strip);
    mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() {
        @Override
        public void onPageStripSelected(int position) {
            position = Math.min(mPagerAdapter.getCount() - 1, position);
            if (mPager.getCurrentItem() != position) {
                mPager.setCurrentItem(position);
            }
        }
    });

    mNextButton = (Button) findViewById(R.id.next_button);
    mPrevButton = (Button) findViewById(R.id.prev_button);
    mSaveButton = (Button) findViewById(R.id.save_button);

    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mStepPagerStrip.setCurrentPage(position);

            if (mConsumePageSelectedEvent) {
                mConsumePageSelectedEvent = false;
                return;
            }

            mEditingAfterReview = false;
            updateBottomBar();
        }
    });

    mNextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mPager.getCurrentItem() == mCurrentPageSequence.size()) {

                if (Auth.getInstance(EntryActivity.this).isLoggedIn()) {
                    DialogFragment dg = new DialogFragment() {
                        @Override
                        public Dialog onCreateDialog(Bundle savedInstanceState) {
                            return new AlertDialog.Builder(getActivity())
                                    .setMessage(R.string.submit_confirm_message)
                                    .setPositiveButton(R.string.submit_confirm_button, mPublishListener)
                                    .setNegativeButton(android.R.string.cancel, null).create();
                        }
                    };
                    dg.show(getSupportFragmentManager(), "publish_entry_dialog");
                } else {
                    DialogFragment dg = new DialogFragment() {
                        @Override
                        public Dialog onCreateDialog(Bundle savedInstanceState) {
                            return new AlertDialog.Builder(getActivity())
                                    .setMessage(R.string.login_required_login)
                                    .setPositiveButton(R.string.login_confirm_button, mLoginListener)
                                    .setNegativeButton(android.R.string.cancel, null).create();
                        }
                    };
                    dg.show(getSupportFragmentManager(), "publish_entry_dialog");
                }
            } else {
                if (mEditingAfterReview) {
                    mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
                } else {
                    mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                }
            }
        }
    });

    mPrevButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        }
    });

    mSaveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            saveEntry();
        }
    });

    onPageTreeChanged();

    if (intent.getAction() == Intent.ACTION_EDIT) {
        mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
    }

    updateBottomBar();
}

From source file:net.simonvt.cathode.ui.HomeActivity.java

@Override
protected void onCreate(Bundle inState) {
    super.onCreate(inState);
    Timber.d("onCreate");
    CathodeApp.inject(this);

    setContentView(R.layout.activity_home);

    ButterKnife.inject(this);

    isTablet = getResources().getBoolean(R.bool.isTablet);

    navigation = (NavigationFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_NAVIGATION);

    watchingParent.setOnTouchListener(new View.OnTouchListener() {
        @Override/*ww w  .j  a va2 s  .  c  o m*/
        public boolean onTouch(View v, MotionEvent event) {
            if (watchingView.isExpanded()) {
                final int action = event.getActionMasked();
                if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
                    watchingView.collapse();
                }

                return true;
            }

            return false;
        }
    });
    watchingView.setWatchingViewListener(watchingListener);

    stack = FragmentStack.forContainer(this, R.id.content, new FragmentStack.Callback() {
        @Override
        public void onStackChanged(int stackSize, Fragment topFragment) {
            Timber.d("onStackChanged: %s", topFragment.getTag());
        }
    });
    stack.setDefaultAnimation(R.anim.fade_in_front, R.anim.fade_out_back, R.anim.fade_in_back,
            R.anim.fade_out_front);
    if (inState != null) {
        stack.restoreState(inState.getBundle(STATE_STACK));
    }
    if (stack.size() == 0) {
        stack.replace(UpcomingShowsFragment.class, FRAGMENT_SHOWS_UPCOMING);
        stack.commit();
    }

    getSupportLoaderManager().initLoader(Loaders.LOADER_SHOW_WATCHING, null, watchingShowCallback);
    getSupportLoaderManager().initLoader(Loaders.LOADER_MOVIE_WATCHING, null, watchingMovieCallback);

    messageBar = new MessageBar(this);

    drawer.setDrawerListener(new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
        }

        @Override
        public void onDrawerOpened(View drawerView) {
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            stack.commit();
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            drawerState = newState;
        }
    });

    if (!Settings.isLoggedIn(this) || isLoginAction(getIntent())) {
        startLoginActivity();
    }
}