Android - Monitoring for keyPress on Service

934 views Asked by At

I have just integrated services into my android app - I am also using startForeground because it's a critical app.

So, my question is - how do I get it to revert the user to the application when they have done a keyPress on the notification / service in their Notification Panel. I have looked everywhere for this and can't find it anywhere...There isn't much point in using services if they don't get directed back to the app onKeyPress so really need to get this working.

Any help is much appreciated.

Thanks

1

There are 1 answers

1
CommonsWare On

So, my question is - how do I get it to revert the user to the application when they have done a keyPress on the notification / service in their Notification Panel.

If the user clicks on the entry in the notification panel (via touchscreen or D-pad), the PendingIntent you supplied via setLatestEventInfo() will be executed. Use an appropriate PendingIntent to bring up the activity you seek. Here is a sample application demonstrating this.