Explicitly ask for option menu in Fragments

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
This commit is contained in:
Lifu Tang
2015-09-23 14:16:13 -07:00
parent 43014ea5bf
commit 4148f17616
2 changed files with 2 additions and 1 deletions

View File

@@ -117,6 +117,7 @@ public class LocationSettings extends LocationSettingsBase
final SettingsActivity activity = (SettingsActivity) getActivity();
mUm = (UserManager) activity.getSystemService(Context.USER_SERVICE);
setHasOptionsMenu(true);
mSwitchBar = activity.getSwitchBar();
mSwitch = mSwitchBar.getSwitch();
mSwitchBar.show();