2 years ago

#50326

test-img

RafsanJany

How can I get back-key press or Long press event in WearOs when my app is in background?

I'm developing a wearOs application, Where I have a feature, app will do something when user long press on physical back-key even my app is background. Currently I'm stuck there. I get the event when my app is foreground but I also want this event when the app is in background.

I used this code to get the event:

override fun onKeyLongPress(keyCode: Int, event: KeyEvent?): Boolean {
    if ( keyCode == KeyEvent.KEYCODE_BACK)
    {
        // Do something
    }
    return super.onKeyLongPress(keyCode, event)
}

Now my question is there any way to get this or any work-around there ??

android

wear-os

0 Answers

Your Answer

Accepted video resources