passing Context into Application?

Johan Vos johan at
Mon Feb 24 01:01:29 PST 2014

That would allow us to put the "dirty" tricks into a non-public method, not
exposed to the application developer.
But I think it would be cleaner, as Tom suggests as well, to provide an
Application.launch(...) method that takes a Context as well?

- Johan

2014-02-24 9:45 GMT+01:00 Richard Bair <richard.bair at>:

> What if you had an AndroidApplication extends Application that added the
> new APIs, such that somebody could specialize behave by using the
> AndroidApplication subclass?
> On Feb 24, 2014, at 9:03 AM, Johan Vos <johan at> wrote:
> > I've been working on using the Android API's in a JavaFX application. As
> > explained in my blog post at
> > we're
> > using a (imo) rather dirty trick.
> > The problem is that all Android API's need to be accessed via a Context
> > instance. The Java FXActivity that we use to bootstrap the JavaFX
> > Application extends Context, but it is only accessible in the JavaFX app
> > since we add it as a static field on FXActivity. When FXActivity calls
> the
> > LauncherImpl to start the application, we can't pass context information.
> > We can pass String[] but that is not useful here.
> >
> > In general, I think the environment that launches a JavaFX Application
> > (Android, iOS, script, JNLP, management software,...) may want to pass
> some
> > context information. Of course this context information is very specific,
> > with Object being the ugly common denominator.
> >
> > I realize it goes against the wora principles, but having the possibility
> > to either inject or set a context on javafx.application.Application would
> > definitely help using JavaFX in other environments.
> >
> > - Johan

More information about the openjfx-dev mailing list