Fix problem with detecting if app is in foreground when app is started from intent