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:Main.java

/**
 * Get parcelable object from bundle if it is not null
 * //w w w  .  j ava 2 s  .c  o m
 * @param key
 * @param bundle
 * @return
 */
@SuppressWarnings("unchecked")
public static <T> T getParcelableFromBundleIfNotNull(String key, Bundle bundle) {
    return (T) (bundle == null ? null : bundle.getParcelable(key));
}

From source file:Main.java

public static void setImageToImageView(Context context, Intent intent, ImageView imageView) {
    Bundle extras = intent.getExtras();
    if (extras != null) {
        photo = extras.getParcelable("data");
        imageView.setImageBitmap(photo);
    }/*from ww w . j a v  a 2 s  .com*/
}

From source file:Main.java

public static Parcelable cloneParcelbleClass(@NonNull Parcelable orange) {
    Bundle bundle = new Bundle();
    bundle.putParcelable("clone", orange);
    return bundle.getParcelable("clone");
}

From source file:Main.java

public static void setPicToView(Intent picdata, ImageView imageView) {
    Bundle extras = picdata.getExtras();
    if (extras != null) {
        Bitmap photo = extras.getParcelable("data");
        imageView.setImageBitmap(photo);
    }// ww w .jav a 2  s  .c  om

}

From source file:com.albedinsky.android.ui.examples.fragment.animation.TransitionFragmentsA.java

static TransitionExample transitionExampleFromArgs(Bundle args) {
    return args != null ? (TransitionExample) args.getParcelable(Extras.EXTRA_TRANSITION_EXAMPLE) : null;
}

From source file:Main.java

public static <T extends Parcelable> Map<String, T> fromBundle(Bundle input, Class<T> c) {
    Map<String, T> output = new HashMap<String, T>();
    for (String key : input.keySet()) {
        output.put(key, c.cast(input.getParcelable(key)));
    }/*from  w  w  w.  ja  va  2s.co m*/
    return output;
}

From source file:Main.java

public static Parcelable interceptParcelableParam(Bundle savedInstanceState, Intent intent, String paramName) {
    Parcelable ret = null;/*from  w  w  w .j  a  v a 2 s  .co m*/

    if (savedInstanceState != null) {
        ret = savedInstanceState.getParcelable(paramName);
    } else {
        if (intent != null) {
            Bundle incomming = intent.getExtras();
            if (incomming != null) {
                ret = incomming.getParcelable(paramName);
            }
        }
    }

    return ret;
}

From source file:Main.java

/**
 * Converts a fragment arguments bundle into an intent.
 *///from  w w w .  ja v a  2s .c om
public static Intent fragmentArgumentsToIntent(Bundle arguments) {
    Intent intent = new Intent();
    if (arguments == null) {
        return intent;
    }

    final Uri data = arguments.getParcelable("_uri");
    if (data != null) {
        intent.setData(data);
    }

    intent.putExtras(arguments);
    intent.removeExtra("_uri");
    return intent;
}

From source file:Main.java

/**
 * Convert a fragment arguments bundle into an intent.
 *//*ww  w.j  a va2 s .  co m*/
public static Intent fragmentArgumentsToIntent(Bundle arguments) {
    Intent intent = new Intent();
    if (arguments == null) {
        return intent;
    }

    final Uri data = arguments.getParcelable(URI_KEY);
    if (data != null) {
        intent.setData(data);
    }

    intent.putExtras(arguments);
    intent.removeExtra(URI_KEY);
    return intent;
}

From source file:ee.ioc.phon.android.speak.Utils.java

public static PendingIntent getPendingIntent(Bundle extras) {
    Parcelable extraResultsPendingIntentAsParceable = extras
            .getParcelable(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT);
    if (extraResultsPendingIntentAsParceable != null) {
        //PendingIntent.readPendingIntentOrNullFromParcel(mExtraResultsPendingIntent);
        if (extraResultsPendingIntentAsParceable instanceof PendingIntent) {
            return (PendingIntent) extraResultsPendingIntentAsParceable;
        }//from   w  w w  .  j a  v a  2  s. c  o  m
    }
    return null;
}