提交 8e9598df 编写于 作者: A Ali Bitek 提交者: Mikkel Nygaard Ravn

Get active Context from the Registrar (#4523)

上级 6bc4e7e9
......@@ -5,3 +5,4 @@
Google Inc.
Jim Simon <jim.j.simon@gmail.com>
Ali Bitek <alibitek@protonmail.ch>
......@@ -92,6 +92,11 @@ public class FlutterPluginRegistry
return mAppContext;
}
@Override
public Context activeContext() {
return (mActivity != null) ? mActivity : mAppContext;
}
@Override
public BinaryMessenger messenger() {
return mNativeView;
......
......@@ -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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册