Android-手机处于锁定或睡眠模式时在应用程序中使用的音量按钮 [英] Android - Volume Buttons used in application when phone is locked or sleep mode
问题描述
我想使用音量按钮控制我的android应用程序,该按钮是否始终在手机后台运行.如果在电话锁定或睡眠模式下按音量按钮一定时间(2/3秒以上),则它将起作用(例如,在锁定/睡眠模式下按音量按钮一定时间,它将增加计数器的值并在打开电话或锁定后显示).
I want to control my android application using volume button which run in phone background all time or not. If i press volume button a certain amount of time (2/3 sec+) in the phone lock or sleep mode then it will work (ex. pressing volume button a certain amount of time in lock/sleep mode it will increase value of a counter and show after open phone or lock).
Android应用程序正在执行以下操作- -应用程序是否在手机后台运行 -按下音量按钮一定时间后,此应用程序将显示吐司或消息
Android application doing these- - application run in phone background or not - after pressing volume button a certain amount of time this application will show a toast or message
有什么方法可以实现这种技术? 有可能.
Is there any way to implement this technique? It is possible or not..
推荐答案
检查github: https://github.com. com/praslnx8/volume_Screen_Lock
它们的作用完全相同.正在运行一项服务,以检测音量按钮是否按下
They are doing exactly the same.. A service is running to detect the volume button pressing
该应用的解决方案: 在服务中以0音量启动媒体播放器.在媒体播放过程中,即使手机处于锁定状态,也可以在收信人处收到动作
Solution from that app: start media player in the service with volume 0. While media play is on the media buton action will be recieved at reciever even when the phone is locked
这篇关于Android-手机处于锁定或睡眠模式时在应用程序中使用的音量按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!