How do you write an extra class for often used code and call it from everywhere?
<p>In my little app users can have a look at 'more information' or send me feedback when they click on <strong>the menu button</strong> (of the device) at <strong>every xml file</strong> of the app.</p>

<p>This is my code (when you click on the menu button):</p>

<pre><code>@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu, menu);
    return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {     
    case R.id.impressum:            
        startActivity(new Intent (this, MoreInformation.class)); 
        break;          
    case R.id.feedback:
        /*
        *
        */
        break;
        }           
    return super.onOptionsItemSelected(item);
}
</code></pre>

<p>Now I put the code into all java classes. This obviously works but I'd like to create a class (Let's call it <code>isMenuButtonPressed.class</code>) which contains the code above and I'd like to remove the code above from all other java classes and just call <code>isMenuButtonPressed.class</code> (in these java classes when the menu button was pressed). How can you do that? How do you pass the information on that the menu button was pressed? How do you receive it in the <code>isMenuButtonPressed.class</code>?</p>

<p>Thanks!</p>
