android-event

Want to Access Power Button events in android

ぃ、小莉子 提交于 2019-11-26 17:05:19
问题 i=0; public boolean onKeyDown(int keyCode, KeyEvent event) { System.out.println("In Key Down Method." + event.getKeyCode()); if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) { i++; System.out.println("Power button pressed."); if (i == 2) { System.out.println("Power button pressed continuoulsy 3 times."); Toast.makeText(MainActivity.this, "Power button pressed " + i + " times.", Toast.LENGTH_SHORT).show(); } else { System.out.println("Power button pressed continuoulsy " + i + " times.");

How to distinguish between move and click in onTouchEvent()?

蹲街弑〆低调 提交于 2019-11-26 09:18:46
问题 In my application, I need to handle both move and click events. A click is a sequence of one ACTION_DOWN action, several ACTION_MOVE actions and one ACTION_UP action. In theory, if you get an ACTION_DOWN event and then an ACTION_UP event - it means that the user has just clicked your View. But in practice, this sequence doesn\'t work on some devices. On my Samsung Galaxy Gio I get such sequences when just clicking my View: ACTION_DOWN, several times ACTION_MOVE, then ACTION_UP. I.e. I get