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.j1024.mcommon.support.GenericFragmentActivity.java

@Override
protected void onCreate(Bundle bundle) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(bundle);
    FrameLayout layout = new FrameLayout(this.getApplicationContext());
    setContentView(layout, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    Bundle args = getIntent().getExtras();
    String fragmentClassName = args.getString(KEY_FRAGMENT_CLASS);

    try {/*from www  . j  a v a 2  s. com*/
        Fragment fragment = (Fragment) Class.forName(fragmentClassName).newInstance();
        Bundle argument = args.getBundle(KEY_FRAGMENT_ARGS);
        fragment.setArguments(argument);

        attachFragment(getSupportFragmentManager(), fragment);
    } catch (Exception e) {
        throw new IllegalStateException("Has error in new instance of fragment");
    }
}

From source file:org.apache.cordova.CordovaInterfaceImpl.java

/**
 * Call this from onCreate() so that any saved startActivityForResult parameters will be restored.
 *///from w  w  w.j  av a  2  s .co m
public void restoreInstanceState(Bundle savedInstanceState) {
    initCallbackService = savedInstanceState.getString("callbackService");
    savedPluginState = savedInstanceState.getBundle("plugin");
    activityWasDestroyed = true;
}

From source file:com.google.android.apps.authenticator.dataimport.Importer.java

/**
 * Imports the contents of the provided {@link Bundle} into the provided {@link AccountDb} and
 * {@link SharedPreferences}. Does not overwrite existing records in the database.
 *
 * @param bundle source bundle.//from  www . ja  v a 2 s. co m
 * @param accountDb destination {@link AccountDb}.
 * @param preferences destination preferences or {@code null} for none.
 */
public void importFromBundle(Bundle bundle, AccountDb accountDb, SharedPreferences preferences) {
    Bundle accountDbBundle = bundle.getBundle(KEY_ACCOUNTS);
    if (accountDbBundle != null) {
        importAccountDbFromBundle(accountDbBundle, accountDb);
    }

    if (preferences != null) {
        Bundle preferencesBundle = bundle.getBundle(KEY_PREFERENCES);
        if (preferencesBundle != null) {
            importPreferencesFromBundle(preferencesBundle, preferences);
        }
    }
}

From source file:it.polimi.spf.demo.couponing.client.coupons.CouponManagerFragment.java

/**
 * Note: since the fragment is retained. the bundle passed in after state is restored is null.
 * THe only way to pass parcelable objects is through the activities onsavedInstanceState and appropiate startup lifecycle
 * However after having second thoughts, since the fragment is retained then all the states and instance variables are
 * retained as well. no need to make the selection states percelable therefore just check for the selectionstate
 * from the multiselector//from w w w.  j a  va  2  s  .c o  m
 */
@Override
public void onActivityCreated(Bundle savedInstanceState) {

    if (mMultiSelector != null) {
        if (savedInstanceState != null) {
            mMultiSelector.restoreSelectionStates(savedInstanceState.getBundle(TAG));
        }

        if (mMultiSelector.isSelectable()) {
            if (mDeleteMode != null) {
                mDeleteMode.setClearOnPrepare(false);
                ((AppCompatActivity) getActivity()).startSupportActionMode(mDeleteMode);
            }

        }
    }

    super.onActivityCreated(savedInstanceState);
}

From source file:ca.rmen.android.scrumchatter.dialog.ConfirmDialogFragment.java

/**
 * @return an AlertDialog with a title, message, ok, and cancel buttons.
 *///from   w  w  w. jav a  2  s. c  om
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    Bundle arguments = getArguments();
    builder.setTitle(arguments.getString(DialogFragmentFactory.EXTRA_TITLE))
            .setMessage(arguments.getString(DialogFragmentFactory.EXTRA_MESSAGE));
    final int actionId = arguments.getInt(DialogFragmentFactory.EXTRA_ACTION_ID);
    final Bundle extras = arguments.getBundle(DialogFragmentFactory.EXTRA_EXTRAS);
    OnClickListener positiveListener = null;
    if (getActivity() instanceof DialogButtonListener) {
        positiveListener = (dialog, which) -> {
            FragmentActivity activity = getActivity();
            if (activity == null)
                Log.w(TAG, "User clicked on dialog after it was detached from activity. Monkey?");
            else
                ((DialogButtonListener) activity).onOkClicked(actionId, extras);
        };
    }
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.setPositiveButton(android.R.string.ok, positiveListener);
    return builder.create();

}

From source file:org.anhonesteffort.flock.ManageSubscriptionActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        if (!DavAccount.build(savedInstanceState.getBundle(KEY_DAV_ACCOUNT_BUNDLE)).isPresent()) {
            Log.e(TAG, "where did my dav account bundle go?! :(");
            finish();/*  w ww .  ja v a 2s  .c  o  m*/
            return;
        }

        davAccount = DavAccount.build(savedInstanceState.getBundle(KEY_DAV_ACCOUNT_BUNDLE)).get();
        currentFragment = savedInstanceState.getInt(KEY_CURRENT_FRAGMENT, -1);
        activityRequestCode = Optional.fromNullable(savedInstanceState.getInt(KEY_REQUEST_CODE));
        activityResultCode = Optional.fromNullable(savedInstanceState.getInt(KEY_RESULT_CODE));
        activityResultData = Optional.fromNullable((Intent) savedInstanceState.getParcelable(KEY_RESULT_DATA));
    }

    super.onRestoreInstanceState(savedInstanceState);
}

From source file:ca.rmen.android.networkmonitor.app.dialog.InfoDialogFragment.java

/**
 * @return a Dialog with a title, message, and single button to dismiss the dialog.
 *///from  w ww  .  java2 s.co  m
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState);
    Context context = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    Bundle arguments = getArguments();
    final int actionId = arguments.getInt(DialogFragmentFactory.EXTRA_ACTION_ID);
    final int iconId = arguments.getInt(DialogFragmentFactory.EXTRA_ICON_ID);
    if (iconId > 0)
        builder.setIcon(iconId);
    final Bundle extras = arguments.getBundle(DialogFragmentFactory.EXTRA_EXTRAS);
    builder.setTitle(arguments.getString(DialogFragmentFactory.EXTRA_TITLE))
            .setMessage(arguments.getString(DialogFragmentFactory.EXTRA_MESSAGE));
    if (getActivity() instanceof InfoDialogListener) {
        OnClickListener neutralListener = new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                FragmentActivity activity = getActivity();
                if (activity == null)
                    Log.w(TAG, "User clicked on dialog after it was detached from activity. Monkey?");
                else
                    ((InfoDialogListener) activity).onNeutralClicked(actionId, extras);
            }
        };
        builder.setNeutralButton(android.R.string.ok, neutralListener);
    }
    if (getActivity() instanceof OnCancelListener)
        builder.setOnCancelListener((OnCancelListener) getActivity());
    final Dialog dialog = builder.create();
    if (getActivity() instanceof OnDismissListener)
        dialog.setOnDismissListener((OnDismissListener) getActivity());
    return dialog;
}

From source file:com.rubixconsulting.walletcracker.WalletCrackerMain.java

protected void restoreState(Bundle savedState) {
    final Bundle state = savedState.getBundle(TAG);

    if (state == null) {
        return;//  w  ww  . j a  v  a 2  s  .  co  m
    }

    initialized = state.getBoolean("initialized", false);

    Log.d(TAG, "restoring currentItem: " + state.getInt("currentItem"));
    pager.setCurrentItem(state.getInt("currentItem", 0), false);

    String tmpAnimState = state.getString("logoAnimationState");
    if (tmpAnimState != null) {
        for (LogoAnimationState animState : LogoAnimationState.values()) {
            if (animState.toString().equals(tmpAnimState)) {
                logoAnimationState = animState;
                break;
            }
        }
    }

    switch (logoAnimationState) {
    case FADING_IN:
    case VISIBLE:
        logoView.setAlpha(MAX_LOGO_ALPHA);
        logoView.setVisibility(View.VISIBLE);
        break;
    }
}

From source file:com.pinkwerther.support.PinkwertherSupport.java

@Override
public void onCreate(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        int i = 0;
        Bundle bundle = savedInstanceState.getBundle(PW_SUB_BUNDLE + i);
        while (bundle != null) {
            mSubBundles.add(bundle);/*  w  ww .j  a v a  2s.c  o m*/
            i++;
            bundle = savedInstanceState.getBundle(PW_SUB_BUNDLE + i);
        }
        RMBundle = savedInstanceState.getBundle(RM_BUNDLE);
        LicenseBundle = savedInstanceState.getBundle(LICENSE_BUNDLE);
        AdsBundle = savedInstanceState.getBundle(ADS_BUNDLE);
    }
    if (mPinkwertherActivity == null) {
        if (getActivity() instanceof PinkwertherActivityInterface)
            mPinkwertherActivity = (PinkwertherActivityInterface) getActivity();
        else
            return;
    }
    super.onCreate(savedInstanceState);
}

From source file:com.money.manager.ex.reports.IncomeVsExpensesChartFragment.java

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

    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(KEY_SAVED_INSTANCE))
            setChartArguments(savedInstanceState.getBundle(KEY_SAVED_INSTANCE));
        if (savedInstanceState.containsKey(KEY_DISPLAY_AS_UP_ENABLED))
            setDisplayHomeAsUpEnabled(savedInstanceState.getBoolean(KEY_DISPLAY_AS_UP_ENABLED));
    }/* w w  w  .  java 2 s.c  o  m*/

    mTextColor = new UIHelper(getActivity()).resolveAttribute(R.attr.chartTextColor);

    // enabled display as home
    //        ActionBarActivity activity = (ActionBarActivity) getActivity();
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (activity != null && activity.getSupportActionBar() != null) {
        activity.getSupportActionBar().setDisplayHomeAsUpEnabled(isDisplayHomeAsUpEnabled());
    }
    // set has option menu
    setHasOptionsMenu(true);
}