add support for new foreground API
Merge pull request #408 from Zahnstocher/patch-9

add support for new foreground API