What is the optimal way to share code between Activities with different base classes?
<p>I have the following problem:<br>
I have an abstract <em>Activity</em> class, lets call it <em>MyAbstractActivity</em>, that contains some code I'd like to reuse (for example: a standard service binder, common menu items, common initialization code, etc. etc.). Normally I would just use it to subclass my concrete activities and be done with it.</p>

<p>However, I occasionally need to use another supertype, such as a <em>ListActivity</em> or a <em>MapActivity</em>.</p>

<h2>So the question is: how do I avoid duplicating that support code within an Activity, if I have to use another base class?</h2>

<p>I have thought up of a solution based on the decorator pattern, like this one:<br>
<a href="http://i.stack.imgur.com/1t906.png" rel="nofollow">LINK TO DIAGRAM</a>.</p>

<p>However, I see a problem with this approach: 
What to do with protected methods (like <em>onCreate()</em>)? Should I introduce an additional "bridge" class that makes them public for the purpose of the decorator, similarly to the way presented below (starting to look a bit byzantine...)?<br>
<a href="http://i.stack.imgur.com/2mVao.png" rel="nofollow">LINK TO DIAGRAM</a><br>
Any other way?</p>

<p>I hope I made myself relatively clear. Thanks in advance for any feedback!</p>

<p>PS. Using static utility classes is not a good solution in my opinion, since it introduces a possibility of hard-to-identify programming bugs.</p>
