Problème intent.putExtra

Problème intent.putExtra - Android - Programmation

Marsh Posté le 20-11-2015 à 10:19:34    

Bonjour amis développeurs !
 
J'ouvre un petit post aujourd'hui car j'aurais besoin d'un petit conseil.
 
J'ai créé une classe user dans une application. Cette classe sera remplit au fur et à mesure des activité qui la compose pour finalement être affiché dans la dernière activité.
 
Pour la création de la classe, tous c'est très bien passé mais j'ai un petit soucis dans le intent.putExtra de mes activités...
 
Je vous montre mes petits bouts de codes.
 
 
 
La classe User
 

Spoiler :

package com.example.shiin.loginregisteralpha;
 
import android.os.Parcel;
import android.os.Parcelable;
 
public class User
{
    private String mName;
    private String mFirstName;
    private String mDate;
    private String mSexe;
    private String mMdp;
    private String mMail;
    private String mSexeFind;
    private String mCity;
    private String mCountry;
    private String mCountryId;
 
 
    public User(String Name, String FirstName,
                String Date, String Sexe, String Mdp,
                String Mail, String SexeFind, String City, String Country, String CountryId)
    {
        super();
        this.mName = Name;
        this.mFirstName = FirstName;
        this.mDate = Date;
        this.mSexe = Sexe;
        this.mMdp = Mdp;
        this.mMail = Mail;
        this.mSexeFind = SexeFind;
        this.mCity = City;
        this.mCountry = Country;
        this.mCountryId = CountryId;
    }
 
    public User(Parcel in) {
        this.mName = in.readString();
        this.mFirstName = in.readString();
        this.mDate = in.readString();
        this.mSexe = in.readString();
        this.mMdp = in.readString();
        this.mMail = in.readString();
        this.mSexeFind = in.readString();
        this.mCity = in.readString();
        this.mCountry = in.readString();
        this.mCountryId = in.readString();
    }
 
    public int describeContents()
    {
        return 0;
    }
 
    public void writeToParcel(Parcel dest, int flags)
    {
        dest.writeString(mName);
        dest.writeString(mFirstName);
        dest.writeString(mDate);
        dest.writeString(mSexe);
        dest.writeString(mMdp);
        dest.writeString(mMail);
        dest.writeString(mSexeFind);
        dest.writeString(mCity);
        dest.writeString(mCountry);
        dest.writeString(mCountryId);
    }
 
    public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>()
    {
        @Override
        public User createFromParcel(Parcel source)
        {
            return new User(source);
        }
 
        @Override
        public User[] newArray(int size)
        {
            return new User[size];
        }
    };
 
    public String getmName()
    {
        return mName;
    }
 
    public String getmFirstName()
    {
        return mFirstName;
    }
 
    public String gemDate()
    {
        return mDate;
    }
 
    public String getmSexe()
    {
        return mSexe;
    }
 
    public String getmMdp()
    {
        return mMdp;
    }
 
    public String getmMail()
    {
        return mMail;
    }
 
    public String getmSexeFind()
    {
        return mSexeFind;
    }
 
    public String getmCity()
    {
        return mCity;
    }
 
    public String getmCountry()
    {
        return mCountry;
    }
 
    public String getmCountryId()
    {
        return mCountryId;
    }
 
    public static Parcelable.Creator<User> getCreator()
    {
        return CREATOR;
    }
 
 
}


 
 
Le fragment d'envoie de donnée de mon activité d'envoi
 
               

Spoiler :

User user = new User(name, firstname, null, null, null, null, null, null, null, null);
                Intent intent = new Intent(getApplicationContext(), RegisterBirth.class);
                intent.putExtra("user", user);
                startActivity(intent);


 
 
Le code d'erreur
 

Spoiler :

Error:(38, 23) error: no suitable method found for putExtra(String,User)
method Intent.putExtra(String,boolean) is not applicable
(argument mismatch; User cannot be converted to boolean)
method Intent.putExtra(String,byte) is not applicable
(argument mismatch; User cannot be converted to byte)
method Intent.putExtra(String,char) is not applicable
(argument mismatch; User cannot be converted to char)
method Intent.putExtra(String,short) is not applicable
(argument mismatch; User cannot be converted to short)
method Intent.putExtra(String,int) is not applicable
(argument mismatch; User cannot be converted to int)
method Intent.putExtra(String,long) is not applicable
(argument mismatch; User cannot be converted to long)
method Intent.putExtra(String,float) is not applicable
(argument mismatch; User cannot be converted to float)
method Intent.putExtra(String,double) is not applicable
(argument mismatch; User cannot be converted to double)
method Intent.putExtra(String,String) is not applicable
(argument mismatch; User cannot be converted to String)
method Intent.putExtra(String,CharSequence) is not applicable
(argument mismatch; User cannot be converted to CharSequence)
method Intent.putExtra(String,Parcelable) is not applicable
(argument mismatch; User cannot be converted to Parcelable)
method Intent.putExtra(String,Parcelable[]) is not applicable
(argument mismatch; User cannot be converted to Parcelable[])
method Intent.putExtra(String,Serializable) is not applicable
(argument mismatch; User cannot be converted to Serializable)
method Intent.putExtra(String,boolean[]) is not applicable
(argument mismatch; User cannot be converted to boolean[])
method Intent.putExtra(String,byte[]) is not applicable
(argument mismatch; User cannot be converted to byte[])
method Intent.putExtra(String,short[]) is not applicable
(argument mismatch; User cannot be converted to short[])
method Intent.putExtra(String,char[]) is not applicable
(argument mismatch; User cannot be converted to char[])
method Intent.putExtra(String,int[]) is not applicable
(argument mismatch; User cannot be converted to int[])
method Intent.putExtra(String,long[]) is not applicable
(argument mismatch; User cannot be converted to long[])
method Intent.putExtra(String,float[]) is not applicable
(argument mismatch; User cannot be converted to float[])
method Intent.putExtra(String,double[]) is not applicable
(argument mismatch; User cannot be converted to double[])
method Intent.putExtra(String,String[]) is not applicable
(argument mismatch; User cannot be converted to String[])
method Intent.putExtra(String,CharSequence[]) is not applicable
(argument mismatch; User cannot be converted to CharSequence[])
method Intent.putExtra(String,Bundle) is not applicable
(argument mismatch; User cannot be converted to Bundle)


Ça risque peut-être de vous sembler élémentaires mais je tourne en rond depuis plusieurs heures, je pense passer à coté de quelque chose....
 
Merci d'avance pour vos réponses !
 
 

Reply

Marsh Posté le 20-11-2015 à 10:19:34   

Reply

Marsh Posté le 24-11-2015 à 09:00:31    

Ta classe User n'implemente pas Parcelable ?

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed