Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 启动活动时意图使应用程序重置_Android_Android Intent - Fatal编程技术网

Android 启动活动时意图使应用程序重置

Android 启动活动时意图使应用程序重置,android,android-intent,Android,Android Intent,我试图通过一个意图将一个类传递给另一个活动,但在创建该活动之前有些东西失败了 以下是主要活动中的调用: Intent intent = new Intent(this, NavigateChartActivity.class); TreeNode selectedOption = chart.getChild(position); Bundle b = new Bundle(); b.putParcelable("Selected", selectedOption);

我试图通过一个意图将一个类传递给另一个活动,但在创建该活动之前有些东西失败了

以下是主要活动中的调用:

Intent intent = new Intent(this, NavigateChartActivity.class);
    TreeNode selectedOption = chart.getChild(position);
    Bundle b = new Bundle();
    b.putParcelable("Selected", selectedOption);
    intent.putExtras(b);

    startActivity(intent);
这是另一个类,也许我在包裹部分实现了一些错误:

public class TreeNode implements Parcelable {

String data = "";
TreeNode parent = null;
List<TreeNode> children;
String question = "";

public TreeNode(String data) {
    this.data = data;
    this.children = new LinkedList<TreeNode>();
    this.question = "";
}

public TreeNode(String data, String q) {
    this.data = data;
    this.children = new LinkedList<TreeNode>();
    this.question = q;
}

public TreeNode() {

}


public TreeNode(Parcel parcel) {
    data = parcel.readString();
    parent = parcel.readTypedObject(TreeNode.CREATOR);
    parcel.readTypedList(children, TreeNode.CREATOR);
    question = parcel.readString();

}


public TreeNode addChild(TreeNode child) {
    child.parent = this;
    this.children.add(child);
    return child;
}



public void addMultipleChilds(TreeNode[] childs){
    for(int i = 0; i < childs.length;i++){
        addChild(childs[i]);
    }
}

public TreeNode getChild(int i){
    return this.children.get(i);
}

public String[] getListOfData(){
    String[] options = new String[this.children.size()];
    for(int i = 0;i<this.children.size();i++){
        options[i] = this.getChild(i).data.toString();
    }
    return options;
}



// Parcelable implementation

@Override
public int describeContents() {
    return 0;
}

@Override

public void writeToParcel(Parcel parcel, int i) {
    parcel.writeString(data);
    parcel.writeTypedObject(parent, i);
    parcel.writeTypedList(children);
    parcel.writeString(question);
}

public static Creator<TreeNode> CREATOR = new Creator<TreeNode>() {
    public TreeNode createFromParcel(Parcel parcel) {
        return new TreeNode(parcel);
    }

    public TreeNode[] newArray(int size) {
        return new TreeNode[size];
    }
};
公共类TreeNode实现可包裹{
字符串数据=”;
TreeNode父节点=null;
列出儿童名单;
字符串问题=”;
公共树节点(字符串数据){
这个数据=数据;
this.children=newlinkedlist();
这个问题=”;
}
公共树节点(字符串数据,字符串q){
这个数据=数据;
this.children=newlinkedlist();
这个问题=q;
}
公共树节点(){
}
公共TreeNode(包裹){
data=parcel.readString();
父对象=parcel.readTypedObject(TreeNode.CREATOR);
parcel.readTypedList(儿童,TreeNode.CREATOR);
问题=parcel.readString();
}
公共树节点添加子节点(树节点子节点){
child.parent=这个;
this.children.add(child);
返回儿童;
}
public void addmultiplechild(树节点[]子节点){
for(int i=0;i对于(int i=0;i@YasmaniLlanes我正在尝试获取它们,但它们会在应用程序重新启动时重置itself@YasmaniLlanes看起来我有>8MB的堆栈,它给了我stackOverflow,这是我收到的消息:致命异常:主进程:com.example.android,PID 9933 java.lang.StackOverflower错误:堆栈大小8MB