I am trying to detect when the power button is pressed in the BroadcastReceiver class, I actually implement it when the administrator permission of the device is activated. I have so many Google, but I can not find it.
In the broadcast class of the receiver, when the screen is on and off, I detect it using this method
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { Log.v("Screen Off", "Screen OFF"); } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { Log.v("Screen ON", "Screen ON"); }
But I have to determine when the power button is pressed. One thing I want to make clear is that there are many applications that run this functionality, for example: https://play.google.com/store/apps/details?id=com.startv.gumrah . Many use this for an SOS application, for example
an emergency application that, when you press the power button of your smartphone 2 times in a row, starts sending warning messages
Please help me how to determine when we press the power button.
source share