Example usage for android.os Bundle getSerializable

List of usage examples for android.os Bundle getSerializable

Introduction

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

Prototype

@Override
@Nullable
public Serializable getSerializable(@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:Main.java

/**
 * Get serializable object from bundle if it is not null
 * /*from  ww  w. ja  va 2s  . c o  m*/
 * @param key
 * @param bundle
 * @return
 */
@SuppressWarnings("unchecked")
public static <T> T getSerializableFromBundleIfNotNull(String key, Bundle bundle) {
    return (T) (bundle == null ? null : bundle.getSerializable(key));
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <T extends Serializable> T getArgument(Bundle bundle, String key, Class<T> clazz) {
    if (bundle != null)
        return (T) bundle.getSerializable(key);
    return null;//w w w.  j  a  va  2 s  .  c o  m
}

From source file:Main.java

public static Map<String, Serializable> bundleToMap(Bundle bundle) {
    Map<String, Serializable> result = new HashMap<String, Serializable>();
    if (bundle == null)
        return result;

    for (String key : bundle.keySet()) {
        result.put(key, bundle.getSerializable(key));
    }//from   w  w  w .j  a  v a2 s . co  m
    return result;
}

From source file:com.facebook.LegacyTokenHelper.java

public static AccessTokenSource getSource(Bundle bundle) {
    Validate.notNull(bundle, "bundle");
    if (bundle.containsKey(TOKEN_SOURCE_KEY)) {
        return (AccessTokenSource) bundle.getSerializable(TOKEN_SOURCE_KEY);
    } else {/*from ww w  .j  av a  2  s  .co  m*/
        boolean isSSO = bundle.getBoolean(IS_SSO_KEY);
        return isSSO ? AccessTokenSource.FACEBOOK_APPLICATION_WEB : AccessTokenSource.WEB_VIEW;
    }
}

From source file:augsburg.se.alltagsguide.page.PageActivity.java

@Override
public Loader<Page> onCreateLoader(int id, Bundle args) {
    AvailableLanguage language = (AvailableLanguage) args.getSerializable(ARG_LANGUAGE);
    if (language == null || language.getLoadedLanguage() == null) {
        Ln.d("AvailableLanguage is null or has no language.");
        return null;
    }// w  ww .j av  a2 s.c om
    return new PageLoader(this, mPrefUtilities.getLocation(), language.getLoadedLanguage(),
            language.getOtherPageId());
}

From source file:de.grobox.liberario.locations.NearbyLocationsLoader.java

public NearbyLocationsLoader(Context context, Bundle args) {
    super(context);

    this.location = (Location) args.getSerializable(LOCATION);
    this.maxDistance = args.getInt(MAX_DISTANCE);
}

From source file:com.shalzz.attendance.controllers.DayController.java

@Override
public Loader<Day> onCreateLoader(int id, Bundle args) {
    Date date = args != null ? (Date) args.getSerializable(DayFragment.ARG_DATE) : new Date();
    return new DayAsyncTaskLoader(mContext, date);
}

From source file:at.bitfire.davdroid.ui.ExceptionInfoFragment.java

@NonNull
@Override//from  www  .  j a v  a 2s  . c  om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle args = getArguments();
    final Exception exception = (Exception) args.getSerializable(ARG_EXCEPTION);
    final Account account = args.getParcelable(ARG_ACCOUNT);

    int title = R.string.exception;
    if (exception instanceof HttpException)
        title = R.string.exception_httpexception;
    else if (exception instanceof IOException)
        title = R.string.exception_ioexception;

    Dialog dialog = new AlertDialog.Builder(getContext()).setIcon(R.drawable.ic_error_dark).setTitle(title)
            .setMessage(exception.getClass().getCanonicalName() + "\n" + exception.getLocalizedMessage())
            .setNegativeButton(R.string.exception_show_details, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent(getContext(), DebugInfoActivity.class);
                    intent.putExtra(DebugInfoActivity.KEY_THROWABLE, exception);
                    if (account != null)
                        intent.putExtra(DebugInfoActivity.KEY_ACCOUNT, account);
                    startActivity(intent);
                }
            }).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).create();
    setCancelable(false);
    return dialog;
}

From source file:com.nadmm.airports.tfr.TfrImageFragment.java

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

    mReceiver = new TfrReceiver();
    mFilter = new IntentFilter();
    mFilter.addAction(TfrImageService.ACTION_GET_TFR_IMAGE);

    Bundle args = getArguments();
    mTfr = (Tfr) args.getSerializable(TfrListActivity.EXTRA_TFR);

    Intent service = new Intent(getActivity(), TfrImageService.class);
    service.setAction(TfrImageService.ACTION_GET_TFR_IMAGE);
    service.putExtra(TfrImageService.TFR_ENTRY, mTfr);
    getActivity().startService(service);
}

From source file:de.grobox.transportr.locations.NearbyLocationsLoader.java

public NearbyLocationsLoader(Context context, TransportNetwork network, Bundle args) {
    super(context);
    this.network = network;

    this.location = (Location) args.getSerializable(LOCATION);
    this.maxDistance = args.getInt(MAX_DISTANCE);
}