Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Detect volume keys when screen is turned off  RSS feed

 
Rohit Savant
Greenhorn
Posts: 21
Fedora Java ME Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to perform some action when I press the volume keys. I can listen to them when the screen is on. However I also want to listen to them when the screen is turned off as well. I tried using wakelock, but it didnt work. Is there any way to get this done? Please let me know.
Thakyou for your support in advance. !
 
Ron McLeod
Saloon Keeper
Posts: 1525
210
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Activities don't run when the screen is off -- you will need to put that functionality in to a Service component instead.

http://developer.android.com/reference/android/app/Service.html
 
Rohit Savant
Greenhorn
Posts: 21
Fedora Java ME Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Thankyou. I will try it and will let you know whether it workedm for me.
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
Thoughts on deprecation in Java
https://coderanch.com/t/683016/java/Deprecation-Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!