I\'ve been reading some posts here on Stackoverflow, and I didn\'t find a good solution, I\'m wondering if it\'s possible to detect when the user long press the power button
I see many answers trying to hookin to the powerbutton. However, wouldn't it be more easy to listen for the shutdown event? I'm not sure if this fits your need, but it seems like it.
Simply register a Broadcastreceiver to the following action(s):