Search code examples
androidcontextual-action-bar

How to get a Contextual Action Bar visibility?


My question is pretty simple.
How can I get a Contextual Action Bar (CAB) visibility?

For instance, I have a ActionMode and a callback.

mActionMode = activity.startActionMode(mCallback);

Now I need to know if the CAB is visible or not. Any ideas?


Solution

  • I guess there is no built-in solution for this problem.

    I have solved it by setting a boolean flag in my callback class

    @Override
    public boolean onCreateActionMode(ActionMode mode, Menu menu)
    {
        this.visible = true;
        /**/
        return true;
    }
    

    and

    @Override
    public void onDestroyActionMode(ActionMode mode)
    {       
        this.visible = false;
        /**/
    }
    

    Then, it is possible to use callback.isVisible();