Changing the Action bar icon

getActionBar();

You're throwing the action bar away right there. getActionBar() returns an instance of ActionBar, which you then need to call setIcon() on. Like so:

ActionBar actionBar = getActionBar();
actionBar.setIcon(R.drawable.my_icon);

Though its a bit late answer but i thought it might be useful.

From inside an activity: For API level 14 or higher:

getActionBar().setIcon(R.drawable.my_icon);

For lower API level we have to extend ActionBarActivity and then:

getSupportActionBar().setIcon(R.drawable.my_icon);

From inside a Fragment: For API level 14 or higher:

getActivity().getActionBar().setIcon(R.drawable.my_icon);

For lower API level we can use (activity must extend ActionBarActivity):

((ActionBarActivity)getActivity()).getSupportActionBar().setIcon(R.drawable.my_icon);

And in both cases we have to call setDisplayShowHomeEnabled(true) before setting the icon or logo.

((ActionBarActivity)getActivity()).getSupportActionBar().setDisplayShowHomeEnabled(true);

((ActionBarActivity)getActivity()).getSupportActionBar().setIcon(R.drawable.my_icon);