Transfer Data between Activities with Android Parcelable


I followed Simon Codrington’s lovely tutorial on transferring data between activities with parcelable and it i was just what I needed. I have an issue however. In the code below, I get the error ‘Expression expected’ on the putExtraData portion of the code. The debugger says “error: cannot find symbol variable ListingsModel”. The class containing the parcelable code is called ‘ListingsModel’ as is the constructor. I can’t seem to locate my error. My intent is wrapped in an if statement that should execute if try and launch the activity ReviewActivity.class and pass all data accordingly. Any help would be greatly appreciated.

Call to new intent:

Intent intent = new Intent(MainActivity.this, ReviewActivity.class);
                            putExtraData("ListingsModel", **ListingsModel**); //error appears here

Class containing parcelable code:

public class ListingsModel implements Parcelable {

    public static final int IMAGE_TYPE = 1;
    public String title, street, city, state, zip, hours, isOpen, content, image, phone, timestamp;
    public int type, rating, ratingCount;
    public Double lat, lng;

    public ListingsModel(int mtype, String mtitle, Integer mrating, Integer mRatingCount, String mstreet, String mcity, String mstate, String mzip, String mhours, String mIsOpen, String mcontent, String mimage, String mphone, Double mlat, Double mlng, String mtimestamp) {
        this.type = mtype;
        this.title = mtitle;
        this.rating = mrating;
        this.ratingCount = mRatingCount;
        this.street = mstreet; = mcity;
        this.state = mstate; = mzip;
        this.hours = mhours;
        this.isOpen = mIsOpen;
        this.content = mcontent;
        this.image = mimage; = mphone; = mlat;
        this.lng = mlng;
        this.timestamp = mtimestamp;

    //write object values to parcel for storage
    public void writeToParcel(Parcel dest, int flags){
        //write all properties to the parcle


    //constructor used for parcel
    public ListingsModel(Parcel parcel){
        //read and set saved values from parcel
        title = parcel.readString();
        rating = parcel.readInt();
        ratingCount = parcel.readInt();
        street = parcel.readString();
        city = parcel.readString();
        state = parcel.readString();
        zip = parcel.readString();
        hours = parcel.readString();
        isOpen = parcel.readString();
        content = parcel.readString();
        image = parcel.readString();
        phone = parcel.readString();
        lat = parcel.readDouble();
        lng = parcel.readDouble();

    //creator - used when un-parceling our parcle (creating the object)
    public static final Parcelable.Creator<ListingsModel> CREATOR = new Parcelable.Creator<ListingsModel>(){

        public ListingsModel createFromParcel(Parcel parcel) {
            return new ListingsModel(parcel);

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

    //return hashcode of object
    public int describeContents() {
        return hashCode();

Hello! Are you sure that that’s the whole code and you didn’t leave out something?

Android studio is quite good at finding errors, however, sometimes the programmer has to do the debugging from the error messages himself. The good thing here is that Android Studio shows messages in the debugging window very thoroughly and makes it easier for the programmer to find the errors. You should try that.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.