我有以下代码在我的应用程序中创建基本配置文件,它包含另一个类的对象,该对象将所有用户的性能数据保存在数组和各种其他原始数据类型中。我将如何在此类中实现 parcelable 接口,以便我可以将用户配置文件对象传递给我的应用程序中的各种活动以进行读取或写入?我是否必须在 Performance 类和这个 Profile 类中实现 parcelable 接口?
public class Profile {
private String name;
private String email;
private Performance Progress;
private int seed;
private int LastRevisionQuestion = 0;
private int[] LastQuestionQuizLinear = {0,0,0};
private int[] tempScoreQuizLinear = {0,0,0};
private int[] LastQuestionQuizRandom = {0,0,0};
private int[] tempScoreQuizRandom = {0,0,0};
private int[] LastQuestionTimedQuizLinear = {0,0,0};
private int[] tempScoreTimedQuizLinear = {0,0,0};
private int[] tempTotalTimeTimedQuizLinear = {0,0,0};
private int[] LastQuestionTimedQuizRandom = {0,0,0};
private int[] tempScoreTimedQuizRandom = {0,0,0};
private int[] tempTotalTimeTimedQuizRandom = {0,0,0};
/**
* Default constructor
*/
public Profile(){
this("ProfileName", "ProfileEmail");
}
/**
* Overloaded constructor takes user name and email address as input parameter to create a new user
* @param name
* @param email
*/
public Profile(String name, String email){
this.name = name;
this.email = email;
setProgress(new Performance());
}
}