Overriding lock/power button in android devices
I would like to know if its possible to override power button in android? I read a lot of posts in Stack Overflow, some saying it's possible and some saying it's not ( example ). What I am trying to achieve is that - when user is using my app he needs to press the lock/power button 5 times to lock the screen. I dont want to override the swtich off functionality only the lock one. Is there anyway to fetch power button callback? I tried WakeLock and disabled the keyguard but it does'nt serve my pupose. I tried out below code from Shink link posted in comments section below: @Override public