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?
Asked
Active
Viewed 2,371 times
3

Psypher
- 10,717
- 12
- 59
- 83

Sartheris Stormhammer
- 2,534
- 8
- 37
- 81
-
Duplicate of http://stackoverflow.com/questions/9996333 – Edward Falk Aug 09 '15 at 22:50
1 Answers
7
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();
}
}

Community
- 1
- 1

Sartheris Stormhammer
- 2,534
- 8
- 37
- 81
-
I had a similar problem with the Nexus 10 API 27 emulator. It worked in the other emulators. This solved my problem. Thank you for sharing. – RickC Jun 03 '18 at 00:51