Android FragmentActivity returns null in getActionBar()

You must extend ActionBarActivity instead of FragmentActivity to have Actionbar with fragments.

If you’re using the v7 appcompat library, your activity should instead extend ActionBarActivity, which is a subclass of FragmentActivity (for more information, read Adding the Action Bar).

Still you can try this,

ActionBar actionBar = (ActionBarActivity)getActivity().getSupportActionBar();

More detail you can found here.

Leave a Comment