Blocked

I am new to Android development and I am trying to create an application.
I want to know if key events can be received even when the phone is locked?

For example, for a music player to change music when I press a button DPAD_CENTER_BUTTON

Doing something like this:

@Override 
public boolean onKeyDown(int keyCode, KeyEvent event) {

    switch (keyCode) {
        case KeyEvent.KEYCODE_ENTER:
        {
            //your Action code
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}

Is it possible?

+5
source share
1 answer

You can use the broadcast receiver for Intent Filter Intent.ACTION_SCREEN_OFF

0
source

All Articles