To have an app bring itself to the foreground when backgrounded, you can install a handler for the digium.app.background.event that decides whether or not to call digium.foreground() to bring itself back to the foreground.
For example, In the callerid sample on lines 73-87
an event handler is installed that runs when the application is backgrounded. You could decide if you should be left in the foreground, and if so, call digium.foreground() in the handler.
You can see the digium.foreground() call used in the callerid example on lines 263-268
. It brings itself to the foreground when a new call is initiated.