开发者

Is there a way to make an android app respond to hardware buttons while phone locked?

I'm working on my first android app. So far I have an activity that reacts to clicks on the hardware volume controls. That's was easy to do, but I'm wondering if there is a 开发者_开发问答way to make it so the app responds to these events from the hardware buttons even while the phone is locked?

I'm really looking for a confirmation of whether or not this can be done. If someone could confirm and give me the general idea of how to do it that would be awesome.


I have not done exactly this but I believe that if you put

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

in your Activity onCreate() you will be able to do what you want even if the screen is locked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜