Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Explicitly ask for option menu in Fragments
Browse files Browse the repository at this point in the history
If a Fragment needs option menu, it has to ask for it explicitly by calling
setHasOptionsMenu(true). If a preference screen contains help URL, this
method is called automatically in the base class. However, if a preference
screen doesn't have help URL, this method will not be called. So any other
extra option menu will not be added correctly.

Typically we won't be able to see this bug. Because on standard Nexus builds,
all settings screen have their own help URL. But on AOSP build, as help URL
is empty by default, if the vendor doesn't modify the resource to provide
their own help URL, we'll end up missing some of the option menus.

Bug: 24241310
Change-Id: Iaabc91a1d102e21254b518ec23459025efbdcc84
  • Loading branch information
Lifu Tang committed Sep 23, 2015
1 parent 43014ea commit 4148f17
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

setHasOptionsMenu(true);
installActionBarToggleSwitch();
}

Expand Down
1 change: 1 addition & 0 deletions src/com/android/settings/location/LocationSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
final SettingsActivity activity = (SettingsActivity) getActivity();
mUm = (UserManager) activity.getSystemService(Context.USER_SERVICE);

setHasOptionsMenu(true);
mSwitchBar = activity.getSwitchBar();
mSwitch = mSwitchBar.getSwitch();
mSwitchBar.show();
Expand Down

0 comments on commit 4148f17

Please sign in to comment.