Hi all,

Bug 1219016 makes us use the application context instead of activity
context in several places in GeckoAppShell. These mostly involve Gecko
callbacks where we can't rely on having an available Activity. Please
look out for potential regressions due to these changes.

This is also a reminder that, when you need a Context and you can
retrieve an Activity or Service instance, use the Activity or Service
instance as the Context. This is almost always the case for front-end
code. However, don't store these instances in static variables because
that could cause memory leaks.

When you do need a static Context, where an Activity or Service is not
available (e.g. in a Gecko callback), use
GeckoAppShell.getApplicationContext() that bug 1219016 is introducing.
However, be aware that this is an application context that has
restrictions on what it can do. In general, don't perform UI
operations, except showing Toasts. System services are available, but
be careful when getting the layout inflator service, search service,
or window service, because what the application context returns can be
different from what an activity context would return. I don't think
there is a definitive guide on application context vs. activity
context, so be careful.

Cheers,
Jim
_______________________________________________
mobile-firefox-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/mobile-firefox-dev

Reply via email to