• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Identifying back button press

Hi all,

Identifying a back button pressed event is veru simple. But I want to do it in different way.
Say my application is installed on a device. Currently user is doing some stuff in Alarm Clock. But now when I press back button or any other button it should no back to the home screen or anywhere but it should open my application. WidgetLocker is the application which is doing the same thing. It uses power button to perform the task. Whenever you press power button from anywhere in the phone it throws to its own customized lock screen.

I want to perform the similar task using some buttons. Can anyone guide me?
 
For you service to be able to do anything as the back button is pressed, you'll need to have it running all the time. Only a broadcast receiver can "wake up" on an event like that.

So you'll need the service running and listening in on the back button somehow. And then trigger whatever reaction you want...

Exactly.. But I think there is no broadcast receiver which can listen that Back Button is pressed.There are receivers for Power button, Camera Button,Search Button etc..

How to do this with services I have no idea.
Can anyone mention few steps to start the same with services.
And first of all is this possible?
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones