Example usage for android.view KeyEvent KEYCODE_MENU

List of usage examples for android.view KeyEvent KEYCODE_MENU

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_MENU.

Prototype

int KEYCODE_MENU

To view the source code for android.view KeyEvent KEYCODE_MENU.

Click Source Link

Document

Key code constant: Menu key.

Usage

From source file:org.disrupted.rumble.userinterface.activity.HomeActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        slidingMenu.toggle();/*from   w  w w .jav  a2s  . com*/
        return true;
    }
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (slidingMenu.isMenuShowing()) {
            slidingMenu.toggle();
            return true;
        }
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.android.camera.ActivityBase.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // Prevent software keyboard or voice search from showing up.
    if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_MENU) {
        if (event.isLongPress())
            return true;
    }/*from  w w w .j  ava2s  . c  o m*/

    return super.onKeyDown(keyCode, event);
}

From source file:net.granoeste.scaffold.app.ScaffoldActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // WTF: LGE Bug... NullPointerException (@PhoneWindow:onKeyUpPanel:1002) {main} - Stack Overflow http://stackoverflow.com/questions/26833242/nullpointerexception-phonewindowonkeyuppanel1002-main
    if (keyCode == KeyEvent.KEYCODE_MENU && "LGE".equalsIgnoreCase(Build.BRAND)) {
        openOptionsMenu();//from  ww w. j a va  2s . c o m
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.dycody.android.idealnote.BaseActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    return keyCode == KeyEvent.KEYCODE_MENU || super.onKeyDown(keyCode, event);
}

From source file:com.appunite.appunitevideoplayer.PlayerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.player_activity);
    root = (ViewGroup) findViewById(R.id.root);
    root.setOnTouchListener(new OnTouchListener() {
        @Override//  w w  w  .  j a v  a  2  s  .co  m
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                toggleControlsVisibility();
            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                view.performClick();
            }
            return true;
        }
    });
    root.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE
                    || keyCode == KeyEvent.KEYCODE_MENU) {
                return false;
            }
            return mediaController.dispatchKeyEvent(event);
        }
    });

    shutterView = findViewById(R.id.shutter);

    videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(this);

    subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_back);
    toolbar.setTitle(getIntent().getStringExtra(TITLE_TEXT_EXTRA));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    mediaController = new MediaController(this);
    mediaController.setAnchorView(root);
    controllerView = (ViewGroup) findViewById(R.id.controller_view);
    controllerView.addView(mediaController);
    CookieHandler currentHandler = CookieHandler.getDefault();
    if (currentHandler != defaultCookieManager) {
        CookieHandler.setDefault(defaultCookieManager);
    }

    audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
    audioCapabilitiesReceiver.register();

    progressBar = (ProgressBar) findViewById(R.id.progress_bar);

    playButton = (ImageView) findViewById(R.id.play_button_icon);
    final int playButtonIconDrawableId = getIntent().getIntExtra(PLAY_BUTTON_EXTRA, 0);
    if (playButtonIconDrawableId != 0) {
        playButton.setImageDrawable(ContextCompat.getDrawable(this, playButtonIconDrawableId));
        playButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                preparePlayer(true);
            }
        });
    }
}

From source file:com.studyjams.mdvideo.PlayerModule.PlayerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.player_activity);
    View root = findViewById(R.id.root);
    root.setOnTouchListener(new OnTouchListener() {
        @Override//from ww w .j  a  v  a 2 s  .  c  o  m
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                toggleControlsVisibility();
            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                view.performClick();
            }
            return true;
        }
    });
    root.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE
                    || keyCode == KeyEvent.KEYCODE_MENU) {
                return false;
            }
            return mediaController.dispatchKeyEvent(event);
        }
    });

    shutterView = findViewById(R.id.shutter);
    //        debugRootView = findViewById(R.id.controls_root);

    videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(this);
    //        debugTextView = (TextView) findViewById(R.id.debug_text_view);

    //        playerStateTextView = (TextView) findViewById(R.id.player_state_view);
    subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles);

    mediaController = new ExtractorMediaController(this);
    mediaController.setAnchorView(root);
    //        retryButton = (Button) findViewById(R.id.retry_button);
    //        retryButton.setOnClickListener(this);
    //        videoButton = (Button) findViewById(R.id.video_controls);
    //        audioButton = (Button) findViewById(R.id.audio_controls);
    //        textButton = (Button) findViewById(R.id.text_controls);

    //?mediaController??window
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    CookieHandler currentHandler = CookieHandler.getDefault();
    if (currentHandler != defaultCookieManager) {
        CookieHandler.setDefault(defaultCookieManager);
    }

    audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
    audioCapabilitiesReceiver.register();
}

From source file:com.volosyukivan.WiFiInputMethod.java

void receivedKey(int code, boolean pressed) {
    if (code == KeyboardHttpServer.FOCUS) {
        for (int key : pressedKeys) {
            sendKey(key, false, false);//www  .  j  av  a 2  s. c om
        }
        pressedKeys.clear();
        resetModifiers();
        return;
    }
    if (pressedKeys.contains(code) == pressed) {
        if (pressed == false)
            return;
        // ignore autorepeat on following keys
        switch (code) {
        case KeyEvent.KEYCODE_ALT_LEFT:
        case KeyEvent.KEYCODE_SHIFT_LEFT:
        case KeyEvent.KEYCODE_HOME:
        case KeyEvent.KEYCODE_MENU:
            return;
        }
    }
    if (pressed) {
        pressedKeys.add(code);
        sendKey(code, pressed, false);
    } else {
        pressedKeys.remove(code);
        sendKey(code, pressed, pressedKeys.isEmpty());
    }
}

From source file:com.geotrackin.gpslogger.GpsMainActivity.java

public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        navigationDrawerFragment.toggleDrawer();
    }// www. j a va 2s  .  c  o  m

    return super.onKeyUp(keyCode, event);
}

From source file:me.xiaopan.android.spear.sample.activity.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        if (drawerLayout.isDrawerOpen(Gravity.START)) {
            drawerLayout.closeDrawer(Gravity.START);
        } else {//from  w ww. j ava 2s  . c o  m
            drawerLayout.openDrawer(Gravity.START);
        }
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}

From source file:com.slim.turboeditor.activity.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        onBackPressed();//from  w w  w  .  jav a  2 s .c  o  m
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MENU) {
        return false;
    } else {
        if (mEditor == null)
            mEditor = findById(this, R.id.editor);

        // this will happen on first key pressed on hard-keyboard only. Once myInputField
        // gets the focus again, it will automatically receive further key presses.

        try {
            if (fileOpened && mEditor != null && !mEditor.hasFocus()) {
                mEditor.requestFocus();
                mEditor.onKeyDown(keyCode, event);
                return true;
            }
        } catch (NullPointerException ex) {
            // Ignore
        }
    }

    return false;
}