Skip to content

Commit

Permalink
Get active Context from the Registrar (flutter#4523)
Browse files Browse the repository at this point in the history
  • Loading branch information
alibitek authored and mravn-google committed Jan 20, 2018
1 parent 6bc4e7e commit 8e9598d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

Google Inc.
Jim Simon <[email protected]>
Ali Bitek <[email protected]>
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public Context context() {
return mAppContext;
}

@Override
public Context activeContext() {
return (mActivity != null) ? mActivity : mAppContext;
}

@Override
public BinaryMessenger messenger() {
return mNativeView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ interface Registrar {
*/
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.
Expand Down

0 comments on commit 8e9598d

Please sign in to comment.