I have a button with openOptionsMenu() method from Activity in it, it works fine on other Android versions, but on KitKat it does absolutely nothing... Why is that?
Apparently you have to override this method from Activity and write some additional code in it, so here is what I did, thanks to the comment of Luis A. Florit from this question How to open the options menu programmatically?
@Override
public void openOptionsMenu() {
super.openOptionsMenu();
Configuration config = getResources().getConfiguration();
if ((config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) > Configuration.SCREENLAYOUT_SIZE_LARGE) {
int originalScreenLayout = config.screenLayout;
config.screenLayout = Configuration.SCREENLAYOUT_SIZE_LARGE;
super.openOptionsMenu();
config.screenLayout = originalScreenLayout;
} else {
super.openOptionsMenu();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With