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

Apps How to get key events when application is in background

How to get key events when application is in background?

I think, but am not sure, that the general way to do this is to register a service that will listen for key events that are not handled by whatever is in the foreground.

My application has more than 20 screens so i am confused that which one is the best approach.
1. one activity and changing the views
2. separate activity for all screens.

This will probably depend greatly on what all of the different screens do. At the most general level, you will probably have a mix, changing views when you work with data differently, and different activities for different data sets.
 
Upvote 0
I think, but am not sure, that the general way to do this is to register a service that will listen for key events that are not handled by whatever is in the foreground.



This will probably depend greatly on what all of the different screens do. At the most general level, you will probably have a mix, changing views when you work with data differently, and different activities for different data sets.

Can you provide any information on any API methods needed to register a service like this? I want to make a service that hooks long presses of the home key and replaces the system Recent Apps screen
 
Upvote 0
Can you provide any information on any API methods needed to register a service like this? I want to make a service that hooks long presses of the home key and replaces the system Recent Apps screen


I need to do a similar thing. Did u find any luck on this post ? any API's or methods to override the native long press of Home Key (detect by a service) ?? Thanks in advance.
 
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