You are asking a valid question. I don't think I have the answer to why your code is crashing. But consider this:
A will contain B, B will have A in it which contains B, which will have A in it which will contain B. . ..
This could be the source of the stack overflow. If you step through the code, at what point does the program crash?
Also, if you may be able to do just fine if you create static class with static functions.
public static class myUtility {
public static void someFunction() { . . .}
}
EDIT: After staring at your code for few minutes, I may have understood what you are trying to do. Let me give it a shot:
Say you want the "dirty" code to be in B. Declare B as abstract:
public abstract class ActivityB extends Activity {
. . .
}
Then for your class A,
public class ActivityA extends Activity implements ActivityB {
}
Is that what you are trying to "achieve"?