After doing more testing and watching how Android behaves with various ActionBar scripts, I found a working solution. Kind of hacks, but this is the only way I found a job. This has nothing to do with the user view ...
Android seems to base the ActionBar on the fragment that it sets when the Activity is created. Let me explain with an example: Let's say we have 1 activity and 2 fragments. Fragment "A" has the following parameters:
getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM);
Fragment "B" has the following options:
getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
When the application starts first and fragment A appears, there is no name. This is normal since I did not include ActionBar.DISPLAY_SHOW_TITLE for fragment A. When I go to fragment B, it also does not display the name. This is where the problem is. Fragment B said to display the name, but it is not.
But if you rotate the phone when fragment B is focused, the name appears. Go back to fragment A, then go back to fragment B, the name is still displayed. Weird ...
If you rotate the phone while focusing on B, a name appears. Go back to fragment A, then go back to fragment B, the name is still displayed. So everything works fine, go back to fragment A, turn the phone around, and we will return to the original problem, just like the application was launched for the first time. So, it seems that Android follows the βrulesβ for displaying on the ActionBar on the fragment that is focused when creating the activity.
This is my decision. It works as I expected:
in fragment A:
getActivity().getActionBar().setTitle(""); getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE);
Then in fragment B:
getActivity().getActionBar().setTitle(R.string.app_name); getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);