camera1.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_ENTER: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); break; case KeyEvent.KEYCODE_DPAD_CENTER: Intent intent2 = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent2); break; case KeyEvent.KEYCODE_BACK: isRunnng=1; Intent close = new Intent(FloatWindowService.this,FloatWindowService.class); stopService(close); break; } return false; } } );
安卓按键监听
最新推荐文章于 2023-08-26 22:24:03 发布