Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

java - Android - Volume Buttons used in application when phone is locked or sleep mode

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 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..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

check the github: https://github.com/praslnx8/volume_Screen_Lock

They are doing exactly the same.. A service is running to detect the volume button pressing

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...