Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,我有一个一键通应用程序。当我按下电源按钮并锁定屏幕时,我的应用程序无法继续运行。我正在使用带有 PARTIAL_WAKE_LOCK 标志的唤醒锁。当用户按下电源按钮时,我如何提供我的应用程序以获取语音消息。
您可以获得电源按钮的按键事件
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) { // Write your logic return true; } return super.dispatchKeyEvent(event); }
希望对你有帮助..