|
|
|
@ -22,7 +22,6 @@ import io.legado.app.utils.postEvent |
|
|
|
|
* Created by GKF on 2018/1/6. |
|
|
|
|
* 监听耳机键 |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
class MediaButtonReceiver : BroadcastReceiver() { |
|
|
|
|
|
|
|
|
|
override fun onReceive(context: Context, intent: Intent) { |
|
|
|
@ -36,8 +35,8 @@ class MediaButtonReceiver : BroadcastReceiver() { |
|
|
|
|
fun handleIntent(context: Context, intent: Intent): Boolean { |
|
|
|
|
val intentAction = intent.action |
|
|
|
|
if (Intent.ACTION_MEDIA_BUTTON == intentAction) { |
|
|
|
|
val keyEvent = |
|
|
|
|
intent.getParcelableExtra<KeyEvent>(Intent.EXTRA_KEY_EVENT) ?: return false |
|
|
|
|
val keyEvent = intent.getParcelableExtra<KeyEvent>(Intent.EXTRA_KEY_EVENT) |
|
|
|
|
?: return false |
|
|
|
|
val keycode: Int = keyEvent.keyCode |
|
|
|
|
val action: Int = keyEvent.action |
|
|
|
|
if (action == KeyEvent.ACTION_DOWN) { |
|
|
|
|