Is there a way to make the Android application respond to hardware buttons when the phone is locked?

I am working on my first Android application. So far, I have activity that responds to clicks on hardware volume controls. It was easy to do, but I wonder if there is a way to do this so that the application responds to these events from the hardware buttons, even when the phone is locked?

I am really looking for confirmation of whether this can be done. If someone could confirm and give me a general idea of ​​how to do this, that would be great.

+3
source share
1 answer

I did not do this, but I think that if you put

getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

onCreate() , , .

0

Source: https://habr.com/ru/post/1758603/


All Articles