I use openOptionsMenu()
to open the menu in applications with special GUI - for example, apps that only show graphics (fullscreen apps without toolbars etc.), upon a long press of the screen.
I can see that I made it work in the past on other applications, and I suppose that it was by using in the Manifest,
android:minSdkVersion="15"
android:targetSdkVersion="15"
I am now unable to make this work (the code would be):
myButton.setOnLongClickListener(
new OnLongClickListener() {
@Override public boolean onLongClick(View v) {
openOptionsMenu();
return false;
}
}
);
I think that Android Studio is using the wrong SDK. In fact,
the values I put in the Manifest ("min" and "target" set to 15) are overridden;
the values used should be those of build.gradle - and again, I set "compile", "min" and "target" set to 15, but I do not see the app working properly and I think the SDK selection may not be happening;
as I check the produced APK the Manifest entries for the SDK (minSdkVersion, targetSdkVersion) are missing.
The build.gradle file according to the Android Studio interface shows:
android {
compileSdkVersion 15
buildToolsVersion "28.0.2"
defaultConfig {
applicationId '[...AppID...]'
minSdkVersion 15
targetSdkVersion 15
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
As written above, the AndroidManifest.xml in the compiled APK (after apktool -d
) does not mention any SDK selection.
I expect that the app compiled for SDK 15 would open the (very required) menu upon call of openOptionsMenu()
. What the compiled app does now, upon debugging, is to go instead in the method that would /close/ the menu (clearly a satanic intention).
EDIT: the information about the specific case of Google butchering openOptionsMenu()
after some SDK version is at
openOptionsMenu function not working in ICS?