1

I am making an application with tabs. In that app same TabView is to be shown in multiple activities in hierarchy. For that i used ActivityGroup.

In my application i can navigate from first activity containing tab to its child activity and can come back to previous activity by pressing a button in child activity. While navigating between these two activities, i get StackOverflowError after few navigations. I tried flag

Intent.FLAG_ACTIVITY_CLEAR_TOP

but it doesn't help. I also tried

finish() 

but it finishes whole ActivityGroup. Then i tried method

finishActivityFromChild() 

but still getting same error.

This is my code for moving from first activity containing tabs to its child-

intent = new Intent(context, ChildActivity.class);
View view = getLocalActivityManager().startActivity("activity2", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) .getDecorView(); 
setContentView(view);
finishActivityFromChild(getCurrentActivity(), 0);

And the same code i am using for coming back to parent activity on click of a button-

public void onClick(View arg0) {
    intent = new Intent(context, ParentActivity.class);
    View view = getLocalActivityManager().startActivity("activity1", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) .getDecorView(); 
setContentView(view);
finishActivityFromChild(getCurrentActivity(), 0);
}

Now i have no idea what to do for this problem. Any help is appreciated. Thanks in advance.

4

1 回答 1

0

我认为一些代码在这里会有所帮助。如果我是你,我会尝试打印出调用的函数,以查看递归调用的函数可能导致堆栈溢出。(一些断点也可以解决问题)

于 2013-03-13T11:40:59.627 回答