Since upgrading the app to SDK 28 it seems that the 3dot overflow menu is not showing up and therefore i lost the menu in my app. Appreciate any suggestions to rectify this issue ?
@Override
public Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.createMenuScene();
/* Just a simple scene with an animated face flying around. */
this.mMainScene = new Scene();
this.mMainScene.setBackground(new Background(0.09804f, 0.6274f, 0.8784f));
final Sprite face = new Sprite(0, 0, this.mFaceTextureRegion, this.getVertexBufferObjectManager());
face.registerEntityModifier(new MoveModifier(30, 0, CAMERA_WIDTH - face.getWidth(), 0, CAMERA_HEIGHT - face.getHeight()));
this.mMainScene.attachChild(face);
return this.mMainScene;
}
@Override
public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) {
if(pKeyCode == KeyEvent.KEYCODE_MENU && pEvent.getAction() == KeyEvent.ACTION_DOWN) {
if(this.mMainScene.hasChildScene()) {
/ Remove the menu and reset it. /
this.mMenuScene.back();
} else {
/ Attach the menu. /
this.mMainScene.setChildScene(this.mMenuScene, false, true, true);
}
return true;
} else {
return super.onKeyDown(pKeyCode, pEvent);
}
}
@Override
public boolean onMenuItemClicked(final MenuScene pMenuScene, final IMenuItem pMenuItem, final float pMenuItemLocalX, final float pMenuItemLocalY) {
switch(pMenuItem.getID()) {
case MENU_RESET:
/ Restart the animation. /
this.mMainScene.reset();
/* Remove the menu and reset it. */
this.mMainScene.clearChildScene();
this.mMenuScene.reset();
return true;
case MENU_QUIT:
/* End Activity. */
this.finish();
return true;
default:
return false;
}
Since upgrading the app to SDK 28 it seems that the 3dot overflow menu is not showing up and therefore i lost the menu in my app. Appreciate any suggestions to rectify this issue ?
here is my code
package com.example.myapplication2;
import org.andengine.engine.camera.Camera; import org.andengine.engine.options.EngineOptions; import org.andengine.engine.options.ScreenOrientation; import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy; import org.andengine.entity.modifier.MoveModifier; import org.andengine.entity.scene.Scene; import org.andengine.entity.scene.background.Background; import org.andengine.entity.scene.menu.MenuScene; import org.andengine.entity.scene.menu.MenuScene.IOnMenuItemClickListener; import org.andengine.entity.scene.menu.item.IMenuItem; import org.andengine.entity.scene.menu.item.SpriteMenuItem; import org.andengine.entity.sprite.Sprite; import org.andengine.entity.util.FPSLogger; import org.andengine.opengl.texture.TextureOptions; import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas; import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; import org.andengine.opengl.texture.region.ITextureRegion; import org.andengine.ui.activity.SimpleBaseGameActivity;
import android.opengl.GLES20; import android.view.KeyEvent;
import android.view.Menu; import android.view.MenuInflater;
/**
@since 01:30:15 - 02.04.2010 */ public class MainActivity extends SimpleBaseGameActivity implements IOnMenuItemClickListener { // =========================================================== // Constants // ===========================================================
private static final int CAMERA_WIDTH = 720; private static final int CAMERA_HEIGHT = 480;
protected static final int MENU_RESET = 0; protected static final int MENU_QUIT = MENU_RESET + 1;
// =========================================================== // Fields // ===========================================================
protected Camera mCamera;
protected Scene mMainScene;
private BitmapTextureAtlas mBitmapTextureAtlas; private ITextureRegion mFaceTextureRegion;
protected MenuScene mMenuScene;
private BitmapTextureAtlas mMenuTexture; protected ITextureRegion mMenuResetTextureRegion; protected ITextureRegion mMenuQuitTextureRegion;
// =========================================================== // Constructors // ===========================================================
// =========================================================== // Getter & Setter // ===========================================================
// =========================================================== // Methods for/from SuperClass/Interfaces // ===========================================================
@Override public EngineOptions onCreateEngineOptions() { this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
}
@Override public void onCreateResources() { BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
}
@Override public Scene onCreateScene() { this.mEngine.registerUpdateHandler(new FPSLogger());
}
@Override public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) { if(pKeyCode == KeyEvent.KEYCODE_MENU && pEvent.getAction() == KeyEvent.ACTION_DOWN) { if(this.mMainScene.hasChildScene()) { / Remove the menu and reset it. / this.mMenuScene.back(); } else { / Attach the menu. / this.mMainScene.setChildScene(this.mMenuScene, false, true, true); } return true; } else { return super.onKeyDown(pKeyCode, pEvent); } }
@Override public boolean onMenuItemClicked(final MenuScene pMenuScene, final IMenuItem pMenuItem, final float pMenuItemLocalX, final float pMenuItemLocalY) { switch(pMenuItem.getID()) { case MENU_RESET: / Restart the animation. / this.mMainScene.reset();
}
// =========================================================== // Methods // ===========================================================
protected void createMenuScene() { this.mMenuScene = new MenuScene(this.mCamera);
}
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu);
}
/* @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_settings: // Do something
}*/
// =========================================================== // Inner and Anonymous Classes // =========================================================== }
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_settings" android:title="@string/action_settings" app:showAsAction="never" /> ...