diff --git a/engine/src/flutter/AUTHORS b/engine/src/flutter/AUTHORS index 35a541722b..6574dff16b 100644 --- a/engine/src/flutter/AUTHORS +++ b/engine/src/flutter/AUTHORS @@ -5,3 +5,4 @@ Google Inc. Jim Simon +Ali Bitek diff --git a/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterPluginRegistry.java b/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterPluginRegistry.java index b4cde77021..9991d98d27 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterPluginRegistry.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterPluginRegistry.java @@ -92,6 +92,11 @@ public class FlutterPluginRegistry return mAppContext; } + @Override + public Context activeContext() { + return (mActivity != null) ? mActivity : mAppContext; + } + @Override public BinaryMessenger messenger() { return mNativeView; diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java index d06e64183c..855377bea7 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java @@ -80,6 +80,13 @@ public interface PluginRegistry { */ Context context(); + /** + * Returns the active {@link Context}. + * + * @return the current {@link #activity() Activity}, if not null, otherwise the {@link #context() Application}. + */ + Context activeContext(); + /** * Returns a {@link BinaryMessenger} which the plugin can use for * creating channels for communicating with the Dart side.