Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Intent; import android.os.Bundle; import android.os.Parcelable; import java.io.Serializable; public class Main { public static <T> void putBundle(String key, T data, Intent intent) { Bundle bundle = new Bundle(); try { if (data instanceof Parcelable) { bundle.putParcelable(key, (Parcelable) data); } else if (data instanceof Serializable) { bundle.putSerializable(key, (Serializable) data); } intent.putExtras(bundle); } catch (Exception e) { e.printStackTrace(); } } }