Pass a document between activities - Android


As the title suggest, i am trying to pass a Document between activities in android.
I tried to use Parcelable via Intent but i didn’t suceed.

Might someone be able to help ?


Hey @heretyk,

Could you post some of your logs and code snippets of where you implemented the Parcelable class with the Intent instance interactions for discussion.


Hi @sweetiewill,

Finally, i have been re-thinking my code, and i realized that just passing the id of the doc to my child activity, and retrieving the Document with that id might be a better way to do it …in terms of operations/ressources (mem,cpu…) usages.

Do you confirm ?

For information, here is what i tried before :

From parent Activity (in a fragment with ListView) :

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        if (null != mListener) {

            // Get Document  "behind" the clicked item
            Document clickedDoc = (Document) mListView.getItemAtPosition(position);
            Intent i = new Intent(getActivity(), ViewProfileActivity.class);
            i.putExtra("clickedDoc",new ParcelableDocument(MainActivity.database,clickedDoc.getId()));



In ViewProfileActivity (child activity) :

    protected Bitmap picture1;

 protected ParcelableDocument documentParcel;

    protected void onCreate(Bundle savedInstanceState) {
        Intent intent = getIntent();
        Bundle data = intent.getExtras();
        documentParcel = data.getParcelable("clickedDoc");
        setContentView(R.layout.activity_view_profile);     // Load the layout

ParcelableDocument Class

public class ParcelableDocument extends Document implements Parcelable {
private int mData;

 * Constructor
 * @param database   The document's owning database
 * @param documentId The document's ID
 * @exclude
public ParcelableDocument(Database database, String documentId) {
    super(database, documentId);

public int describeContents() {
    return 0;

public void writeToParcel(Parcel out, int flags) {

public static final Parcelable.Creator<ParcelableDocument> CREATOR
        = new Parcelable.Creator<ParcelableDocument>() {
    public ParcelableDocument createFromParcel(Parcel source) {
        return null;

    public ParcelableDocument[] newArray(int size) {
        return new ParcelableDocument[size];


Best regards,