Java tutorial
//package com.java2s; //License from project: Apache License import android.os.Bundle; public class Main { /** * Get parcelable object from bundle if it is not null * * @param key * @param bundle * @return */ @SuppressWarnings("unchecked") public static <T> T getParcelableFromBundleIfNotNull(String key, Bundle bundle) { return (T) (bundle == null ? null : bundle.getParcelable(key)); } }