How to close an ActionMode menu programmatically on Honeycomb?

android, android-3.0-honeycomb, android-fragments, contextual-action-bar

Solution

Whenever you are creating/starting ActionMode Create by

mMode = startActionMode(....);

To Dismiss it use following Syntax

if (mMode != null) 
 {
     mMode.finish();
 }

Problem

In my application there is a ListFragment where each item from the list contains a checkbox. Whenever the user clicks on one of those checkboxes the app starts an ActionMode context menu. But I want the application to close the ActionMode menu when clicking on another component. I tried `Fragment#closeContextMenu()` without success. Any ideas how can I accomplish that?

Original source