Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6849993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:04:09+00:00 2026-05-27T01:04:09+00:00

I want to pass on object between two activities in Android which has lead

  • 0

I want to pass on object between two activities in Android which has lead me to parcelable classes. I am not trying to convert my current class but don’t understand the Parcelable.Creator method.

This is what I have so far

public class Account implements Parcelable{

/**
 * Declare private variables
 */

private String fName;
private String lName;
private String screenName;
private String email;
private String level;
private int userId;
//private Context myContext;

/**
 * Account constructor
 */

public Account(String fName, String lName, String sName, String email, String level, String x) throws Exception{    


    /**Parse userId into int */
    this.userId = Integer.parseInt(x);

    /**Select from DB user details */


    /**Initialize variables with results */
    this.setfName(fName);
    this.setlName(lName);
    this.setScreenName(sName);
    this.setEmail(email);
    this.setLevel(level);



}

@Override
public int describeContents() {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public void writeToParcel(Parcel out, int flags) {
    // TODO Auto-generated method stub
    out.writeString(fName);
    out.writeString(lName);
    out.writeString(screenName);
    out.writeString(email);
    out.writeString(level);
    out.writeInt(userId);

}

// this is used to regenerate your object. All Parcelables must have a CREATOR that implements these two methods
public static final Parcelable.Creator<Account> CREATOR = new Parcelable.Creator<Account>() {
    public Account createFromParcel(Parcel in) {
        return new Account(in);
    }

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



/**
 * Getters and setters for all variables from Account class
 */

public int getUserId(){
    return userId;
}

public String getScreenName() {
    return screenName;
}

public void setScreenName(String screenName) {
    this.screenName = screenName;
}

public String getfName() {
    return fName;
}

public void setfName(String fName) {
    this.fName = fName;
}

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}

public String getLevel() {
    return level;
}

public void setLevel(String level) {
    this.level = level;
}

public String getlName() {
    return lName;
}

public void setlName(String lName) {
    this.lName = lName;
}



}

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:04:10+00:00Added an answer on May 27, 2026 at 1:04 am
    public static final Parcelable.Creator CREATOR =
        new Parcelable.Creator() {
            public ObjectB createFromParcel(Parcel in) {
                return new ObjectB(in);
            }
    
            public ObjectB[] newArray(int size) {
                return new ObjectB[size];
            }
        };
    

    This field is needed for Android to be able to create new objects, individually or as arrays. This also means that you can use use the default constructor to create the object and use another method to hyrdate it as necessary.

    Look at this Android – Parcelable

    Online tool for creating Parcelable class

    and http://www.appance.com/tag/parcelable/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two activities in which I need to pass an object array between
I want to create light object data-package to pass between client and server applications.
I have two controllers , and I have one object. I want to pass
I want to pass a C# object between win forms. At the moment, I
I want to pass a varying number of parameters between two objects. I have
I am trying to pass data between two pages using Session State in ASP.NET.
I need to pass a List of my objects between activities. I do not
All i want is to pass a HTML (DOM object) from javascript to Actionscript.
In short, I want to use an object literal to allow me to pass
I want to implement drag and drop between two components within the same JVM.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.