I have developed an application in which i have 4 tabs A,B,C,D. Each of the Tab contains an Activity. In the fourth tab D I have added an ActivityGroup in which I am having 3 mo
I suppose you have an infinite loop somewhere.
Probably you've added the same instance of a view twice somewhere in your hierarchy and now you've got a cycle.
Fix that. And fix your layout. I can't see a reason to have such a complex layout.
I have search all over the Google but couldn't find a solution. Then I have just came up with this idea and it works perfectly on my old Samsung Galaxy Nexus and the Vodafone VF695!
Here is my hack in the root FrameLayout of my very deep layout:
public class StackFrameLayout extends FrameLayout {
private boolean stackOverflow;
@Override
public void draw(final Canvas canvas) {
if (stackOverflow) {
stackDraw(canvas);
} else {
try {
super.draw(canvas);
} catch (StackOverflowError e) {
stackOverflow = true;
stackDraw(canvas);
}
}
}
public void stackDraw(final Canvas canvas) {
Thread thread = new Thread(getContext().getMainLooper().getThread().getThreadGroup(), new Runnable() {
@Override
public void run() {
StackFrameLayout.super.draw(canvas);
}
}, "draw-thread", 2000000);
thread.start();
try {
thread.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
So basically I passed the complicated drawing methods into a thread with larger stack size. So the stack of the methods called will stop increasing a that point. Then the UI thread wait for the drawing thread to finish its work and then continue to ensure it draw sequentially like running on the UI thread.