Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5ea125e

Browse files
Switch PlatformViewsController from Activity ref to Application ref. (#9193)
1 parent fd4368c commit 5ea125e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

shell/platform/android/io/flutter/app/FlutterPluginRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public Registrar registrarFor(String pluginKey) {
8080
public void attach(FlutterView flutterView, Activity activity) {
8181
mFlutterView = flutterView;
8282
mActivity = activity;
83-
mPlatformViewsController.attach(activity, flutterView, flutterView.getDartExecutor());
83+
mPlatformViewsController.attach(activity.getApplicationContext(), flutterView, flutterView.getDartExecutor());
8484
}
8585

8686
public void detach() {

shell/platform/android/io/flutter/embedding/engine/plugins/shim/ShimPluginRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public <T> T valuePublishedByPlugin(String pluginKey) {
7575

7676
//----- From FlutterPluginRegistry that aren't in the PluginRegistry interface ----//
7777
public void attach(FlutterView flutterView, Activity activity) {
78-
platformViewsController.attach(activity, flutterEngine.getRenderer(), flutterEngine.getDartExecutor());
78+
platformViewsController.attach(activity.getApplicationContext(), flutterEngine.getRenderer(), flutterEngine.getDartExecutor());
7979
}
8080

8181
public void detach() {

shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public PlatformViewsController() {
227227
* Attaches this platform views controller to its input and output channels.
228228
*
229229
* @param context The base context that will be passed to embedded views created by this controller.
230-
* This should be the context of the Activity hosting the Flutter application.
230+
* This should be the {@code Application} {@code Context}.
231231
* @param textureRegistry The texture registry which provides the output textures into which the embedded views
232232
* will be rendered.
233233
* @param dartExecutor The dart execution context, which is used to setup a system channel.
@@ -239,7 +239,7 @@ public void attach(Context context, TextureRegistry textureRegistry, @NonNull Da
239239
"attach was called while the PlatformViewsController was already attached."
240240
);
241241
}
242-
this.context = context;
242+
this.context = context.getApplicationContext();
243243
this.textureRegistry = textureRegistry;
244244
platformViewsChannel = new PlatformViewsChannel(dartExecutor);
245245
platformViewsChannel.setPlatformViewsHandler(channelHandler);

0 commit comments

Comments
 (0)