Hey Simon. I've disappointing news. I've tested your Java action in Mendix 5.20.0 as an anonymous user and as logged in user. The Mendix function 'getContext().getSession().getUserAgent()' doesn't return the browser info when it's an anonymous user. In Mendix 6.6.0 doesn't work either.
I advice you to report an issue at Mendix support: support.mendix.com.