user1996510
user1996510

Reputation:

Hardware volume button not working on locked phone

I am developing a simple app in which i am the counting of volume button press 3 times. If counter is equal to three then some action will happen.

My problem is when i press the hardware volume button when phone is locked then onReceive() method of BroadcastReceiver is not called. Its working fine when phone is unlocked.

Is there any way or trick that When i press volume up button in locked mode then my counter increase and vice versa.

Upvotes: 1

Views: 1090

Answers (1)

user1996510
user1996510

Reputation:

I researched on this and conclusion is that Its is not possible.

But I did in some way but its not good approach because It will drain the battery too much.

I start the media player in background with zero volume. Now volume keys start working when even mobile is locked. As example Music app in which volume buttons work even when mobile is locked.

Upvotes: 0

Related Questions