Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Package Functions | List of all members
io.flutter.embedding.engine.FlutterEngineConnectionRegistry Class Reference
Inheritance diagram for io.flutter.embedding.engine.FlutterEngineConnectionRegistry:
io.flutter.embedding.engine.plugins.PluginRegistry io.flutter.embedding.engine.plugins.activity.ActivityControlSurface io.flutter.embedding.engine.plugins.service.ServiceControlSurface io.flutter.embedding.engine.plugins.broadcastreceiver.BroadcastReceiverControlSurface io.flutter.embedding.engine.plugins.contentprovider.ContentProviderControlSurface

Public Member Functions

void destroy ()
 
void add (@NonNull FlutterPlugin plugin)
 
void add (@NonNull Set< FlutterPlugin > plugins)
 
boolean has (@NonNull Class<? extends FlutterPlugin > pluginClass)
 
FlutterPlugin get (@NonNull Class<? extends FlutterPlugin > pluginClass)
 
void remove (@NonNull Class<? extends FlutterPlugin > pluginClass)
 
void remove (@NonNull Set< Class<? extends FlutterPlugin > > pluginClasses)
 
void removeAll ()
 
void attachToActivity ( @NonNull ExclusiveAppComponent< Activity > exclusiveActivity, @NonNull Lifecycle lifecycle)
 
void detachFromActivityForConfigChanges ()
 
void detachFromActivity ()
 
boolean onRequestPermissionsResult (int requestCode, @NonNull String[] permissions, @NonNull int[] grantResult)
 
boolean onActivityResult (int requestCode, int resultCode, @Nullable Intent data)
 
void onNewIntent (@NonNull Intent intent)
 
void onUserLeaveHint ()
 
void onSaveInstanceState (@NonNull Bundle bundle)
 
void onRestoreInstanceState (@Nullable Bundle bundle)
 
void attachToService ( @NonNull Service service, @Nullable Lifecycle lifecycle, boolean isForeground)
 
void detachFromService ()
 
void onMoveToForeground ()
 
void onMoveToBackground ()
 
void attachToBroadcastReceiver ( @NonNull BroadcastReceiver broadcastReceiver, @NonNull Lifecycle lifecycle)
 
void detachFromBroadcastReceiver ()
 
void attachToContentProvider ( @NonNull ContentProvider contentProvider, @NonNull Lifecycle lifecycle)
 
void detachFromContentProvider ()
 
void add (@NonNull FlutterPlugin plugin)
 
void add (@NonNull Set< FlutterPlugin > plugins)
 
boolean has (@NonNull Class<? extends FlutterPlugin > pluginClass)
 
FlutterPlugin get (@NonNull Class<? extends FlutterPlugin > pluginClass)
 
void remove (@NonNull Class<? extends FlutterPlugin > pluginClass)
 
void remove (@NonNull Set< Class<? extends FlutterPlugin > > plugins)
 
void removeAll ()
 
void attachToActivity ( @NonNull ExclusiveAppComponent< Activity > exclusiveActivity, @NonNull Lifecycle lifecycle)
 
void detachFromActivityForConfigChanges ()
 
void detachFromActivity ()
 
boolean onRequestPermissionsResult (int requestCode, @NonNull String[] permissions, @NonNull int[] grantResult)
 
boolean onActivityResult (int requestCode, int resultCode, @Nullable Intent data)
 
void onNewIntent (@NonNull Intent intent)
 
void onUserLeaveHint ()
 
void onSaveInstanceState (@NonNull Bundle bundle)
 
void onRestoreInstanceState (@Nullable Bundle bundle)
 
void attachToService ( @NonNull Service service, @Nullable Lifecycle lifecycle, boolean isForeground)
 
void detachFromService ()
 
void onMoveToForeground ()
 
void onMoveToBackground ()
 
void attachToBroadcastReceiver ( @NonNull BroadcastReceiver broadcastReceiver, @NonNull Lifecycle lifecycle)
 
void detachFromBroadcastReceiver ()
 
void attachToContentProvider ( @NonNull ContentProvider contentProvider, @NonNull Lifecycle lifecycle)
 
void detachFromContentProvider ()
 

Package Functions

 FlutterEngineConnectionRegistry ( @NonNull Context appContext, @NonNull FlutterEngine flutterEngine, @NonNull FlutterLoader flutterLoader, @Nullable FlutterEngineGroup group)
 

Detailed Description

This class is owned by the io.flutter.embedding.engine.FlutterEngine and its role is to managed its connections with Android App Components and Flutter plugins.

It enforces the {0|1}:1 relationship between activity and engine, and propagates the app component connection to the plugins.

Definition at line 48 of file FlutterEngineConnectionRegistry.java.

Constructor & Destructor Documentation

◆ FlutterEngineConnectionRegistry()

io.flutter.embedding.engine.FlutterEngineConnectionRegistry.FlutterEngineConnectionRegistry ( @NonNull Context  appContext,
@NonNull FlutterEngine  flutterEngine,
@NonNull FlutterLoader  flutterLoader,
@Nullable FlutterEngineGroup  group 
)
inlinepackage

Definition at line 97 of file FlutterEngineConnectionRegistry.java.

101 {
102 this.flutterEngine = flutterEngine;
103 pluginBinding =
104 new FlutterPlugin.FlutterPluginBinding(
105 appContext,
106 flutterEngine,
107 flutterEngine.getDartExecutor(),
108 flutterEngine.getRenderer(),
109 flutterEngine.getPlatformViewsController().getRegistry(),
110 new DefaultFlutterAssets(flutterLoader),
111 group);
112 }
PlatformViewsController getPlatformViewsController()

Member Function Documentation

◆ add() [1/2]

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.add ( @NonNull FlutterPlugin  plugin)
inline

Attaches the given plugin to the io.flutter.embedding.engine.FlutterEngine associated with this PluginRegistry.

Implements io.flutter.embedding.engine.plugins.PluginRegistry.

Definition at line 127 of file FlutterEngineConnectionRegistry.java.

127 {
128 try (TraceSection e =
129 TraceSection.scoped(
130 "FlutterEngineConnectionRegistry#add " + plugin.getClass().getSimpleName())) {
131 if (has(plugin.getClass())) {
132 Log.w(
133 TAG,
134 "Attempted to register plugin ("
135 + plugin
136 + ") but it was "
137 + "already registered with this FlutterEngine ("
138 + flutterEngine
139 + ").");
140 return;
141 }
142
143 Log.v(TAG, "Adding plugin: " + plugin);
144 // Add the plugin to our generic set of plugins and notify the plugin
145 // that is has been attached to an engine.
146 plugins.put(plugin.getClass(), plugin);
147 plugin.onAttachedToEngine(pluginBinding);
148
149 // For ActivityAware plugins, add the plugin to our set of ActivityAware
150 // plugins, and if this engine is currently attached to an Activity,
151 // notify the ActivityAware plugin that it is now attached to an Activity.
152 if (plugin instanceof ActivityAware) {
153 ActivityAware activityAware = (ActivityAware) plugin;
154 activityAwarePlugins.put(plugin.getClass(), activityAware);
155
156 if (isAttachedToActivity()) {
157 activityAware.onAttachedToActivity(activityPluginBinding);
158 }
159 }
160
161 // For ServiceAware plugins, add the plugin to our set of ServiceAware
162 // plugins, and if this engine is currently attached to a Service,
163 // notify the ServiceAware plugin that it is now attached to a Service.
164 if (plugin instanceof ServiceAware) {
165 ServiceAware serviceAware = (ServiceAware) plugin;
166 serviceAwarePlugins.put(plugin.getClass(), serviceAware);
167
168 if (isAttachedToService()) {
169 serviceAware.onAttachedToService(servicePluginBinding);
170 }
171 }
172
173 // For BroadcastReceiverAware plugins, add the plugin to our set of BroadcastReceiverAware
174 // plugins, and if this engine is currently attached to a BroadcastReceiver,
175 // notify the BroadcastReceiverAware plugin that it is now attached to a BroadcastReceiver.
176 if (plugin instanceof BroadcastReceiverAware) {
177 BroadcastReceiverAware broadcastReceiverAware = (BroadcastReceiverAware) plugin;
178 broadcastReceiverAwarePlugins.put(plugin.getClass(), broadcastReceiverAware);
179
180 if (isAttachedToBroadcastReceiver()) {
181 broadcastReceiverAware.onAttachedToBroadcastReceiver(broadcastReceiverPluginBinding);
182 }
183 }
184
185 // For ContentProviderAware plugins, add the plugin to our set of ContentProviderAware
186 // plugins, and if this engine is currently attached to a ContentProvider,
187 // notify the ContentProviderAware plugin that it is now attached to a ContentProvider.
188 if (plugin instanceof ContentProviderAware) {
189 ContentProviderAware contentProviderAware = (ContentProviderAware) plugin;
190 contentProviderAwarePlugins.put(plugin.getClass(), contentProviderAware);
191
192 if (isAttachedToContentProvider()) {
193 contentProviderAware.onAttachedToContentProvider(contentProviderPluginBinding);
194 }
195 }
196 }
197 }
boolean has(@NonNull Class<? extends FlutterPlugin > pluginClass)
void Log(const char *format,...) SK_PRINTF_LIKE(1
Definition: TestRunner.cpp:137

◆ add() [2/2]

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.add ( @NonNull Set< FlutterPlugin plugins)
inline

Attaches the given plugins to the io.flutter.embedding.engine.FlutterEngine associated with this PluginRegistry.

Implements io.flutter.embedding.engine.plugins.PluginRegistry.

Definition at line 200 of file FlutterEngineConnectionRegistry.java.

200 {
201 for (FlutterPlugin plugin : plugins) {
202 add(plugin);
203 }
204 }

◆ attachToActivity()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.attachToActivity ( @NonNull ExclusiveAppComponent< Activity >  exclusiveActivity,
@NonNull Lifecycle  lifecycle 
)
inline

Call this method from the ExclusiveAppComponent that is displaying the visual content of the io.flutter.embedding.engine.FlutterEngine that is associated with this
ActivityControlSurface
.

Once an ExclusiveAppComponent is created, and its associated io.flutter.embedding.engine.FlutterEngine is executing Dart code, the ExclusiveAppComponent should invoke this method. At that point the io.flutter.embedding.engine.FlutterEngine is considered "attached" to the ExclusiveAppComponent and all ActivityAware plugins are given access to the ExclusiveAppComponent's android.app.Activity.

Implements io.flutter.embedding.engine.plugins.activity.ActivityControlSurface.

Definition at line 314 of file FlutterEngineConnectionRegistry.java.

315 {
316 try (TraceSection e = TraceSection.scoped("FlutterEngineConnectionRegistry#attachToActivity")) {
317 if (this.exclusiveActivity != null) {
318 this.exclusiveActivity.detachFromFlutterEngine();
319 }
320 // If we were already attached to an app component, detach from it.
321 detachFromAppComponent();
322 this.exclusiveActivity = exclusiveActivity;
323 attachToActivityInternal(exclusiveActivity.getAppComponent(), lifecycle);
324 }
325 }

◆ attachToBroadcastReceiver()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.attachToBroadcastReceiver ( @NonNull BroadcastReceiver  broadcastReceiver,
@NonNull Lifecycle  lifecycle 
)
inline

Call this method from the BroadcastReceiver that is running the io.flutter.embedding.engine.FlutterEngine that is associated with this
BroadcastReceiverControlSurface
.

Once a BroadcastReceiver is created, and its associated io.flutter.embedding.engine.FlutterEngine is executing Dart code, the BroadcastReceiver should invoke this method. At that point the io.flutter.embedding.engine.FlutterEngine is considered "attached" to the BroadcastReceiver and all BroadcastReceiverAware plugins are given access to the BroadcastReceiver.

Implements io.flutter.embedding.engine.plugins.broadcastreceiver.BroadcastReceiverControlSurface.

Definition at line 560 of file FlutterEngineConnectionRegistry.java.

561 {
562 try (TraceSection e =
563 TraceSection.scoped("FlutterEngineConnectionRegistry#attachToBroadcastReceiver")) {
564 // If we were already attached to an Android component, detach from it.
565 detachFromAppComponent();
566
567 this.broadcastReceiver = broadcastReceiver;
568 this.broadcastReceiverPluginBinding =
569 new FlutterEngineBroadcastReceiverPluginBinding(broadcastReceiver);
570 // TODO(mattcarroll): resolve possibility of different lifecycles between this and engine
571 // attachment
572
573 // Notify all BroadcastReceiverAware plugins that they are now attached to a new
574 // BroadcastReceiver.
575 for (BroadcastReceiverAware broadcastReceiverAware : broadcastReceiverAwarePlugins.values()) {
576 broadcastReceiverAware.onAttachedToBroadcastReceiver(broadcastReceiverPluginBinding);
577 }
578 }
579 }

◆ attachToContentProvider()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.attachToContentProvider ( @NonNull ContentProvider  contentProvider,
@NonNull Lifecycle  lifecycle 
)
inline

Call this method from the ContentProvider that is running the io.flutter.embedding.engine.FlutterEngine that is associated with this
ContentProviderControlSurface
.

Once a ContentProvider is created, and its associated io.flutter.embedding.engine.FlutterEngine is executing Dart code, the ContentProvider should invoke this method. At that point the io.flutter.embedding.engine.FlutterEngine is considered "attached" to the ContentProvider and all ContentProviderAware plugins are given access to the ContentProvider.

Implements io.flutter.embedding.engine.plugins.contentprovider.ContentProviderControlSurface.

Definition at line 608 of file FlutterEngineConnectionRegistry.java.

609 {
610
611 try (TraceSection e =
612 TraceSection.scoped("FlutterEngineConnectionRegistry#attachToContentProvider")) {
613 // If we were already attached to an Android component, detach from it.
614 detachFromAppComponent();
615
616 this.contentProvider = contentProvider;
617 this.contentProviderPluginBinding =
618 new FlutterEngineContentProviderPluginBinding(contentProvider);
619 // TODO(mattcarroll): resolve possibility of different lifecycles between this and engine
620 // attachment
621
622 // Notify all ContentProviderAware plugins that they are now attached to a new
623 // ContentProvider.
624 for (ContentProviderAware contentProviderAware : contentProviderAwarePlugins.values()) {
625 contentProviderAware.onAttachedToContentProvider(contentProviderPluginBinding);
626 }
627 }
628 }

◆ attachToService()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.attachToService ( @NonNull Service  service,
@Nullable Lifecycle  lifecycle,
boolean  isForeground 
)
inline

Call this method from the Service that is running the io.flutter.embedding.engine.FlutterEngine that is associated with this
ServiceControlSurface
.

Once a Service is created, and its associated io.flutter.embedding.engine.FlutterEngine is executing Dart code, the Service should invoke this method. At that point the io.flutter.embedding.engine.FlutterEngine is considered "attached" to the Service and all ServiceAware plugins are given access to the Service.

isForeground should be true if the given Service is running in the foreground, false otherwise.

Implements io.flutter.embedding.engine.plugins.service.ServiceControlSurface.

Definition at line 499 of file FlutterEngineConnectionRegistry.java.

500 {
501 try (TraceSection e = TraceSection.scoped("FlutterEngineConnectionRegistry#attachToService")) {
502 // If we were already attached to an Android component, detach from it.
503 detachFromAppComponent();
504
505 this.service = service;
506 this.servicePluginBinding = new FlutterEngineServicePluginBinding(service, lifecycle);
507
508 // Notify all ServiceAware plugins that they are now attached to a new Service.
509 for (ServiceAware serviceAware : serviceAwarePlugins.values()) {
510 serviceAware.onAttachedToService(servicePluginBinding);
511 }
512 }
513 }

◆ destroy()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.destroy ( )
inline

Definition at line 114 of file FlutterEngineConnectionRegistry.java.

114 {
115 Log.v(TAG, "Destroying.");
116 // Detach from any Android component that we may currently be attached to, e.g., Activity,
117 // Service, BroadcastReceiver, ContentProvider. This must happen before removing all plugins so
118 // that the plugins have an opportunity to clean up references as a result of component
119 // detachment.
120 detachFromAppComponent();
121
122 // Remove all registered plugins.
123 removeAll();
124 }

◆ detachFromActivity()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.detachFromActivity ( )
inline

Call this method from the android.app.Activity that is attached to this
ActivityControlSurfaces
's io.flutter.embedding.engine.FlutterEngine when the android.app.Activity is about to be destroyed for non-configuration-change reasons.

This method gives each ActivityAware plugin an opportunity to clean up its references before the is destroyed.

Implements io.flutter.embedding.engine.plugins.activity.ActivityControlSurface.

Definition at line 376 of file FlutterEngineConnectionRegistry.java.

376 {
377 if (isAttachedToActivity()) {
378 try (TraceSection e =
379 TraceSection.scoped("FlutterEngineConnectionRegistry#detachFromActivity")) {
380 for (ActivityAware activityAware : activityAwarePlugins.values()) {
381 activityAware.onDetachedFromActivity();
382 }
383
384 detachFromActivityInternal();
385 }
386 } else {
387 Log.e(TAG, "Attempted to detach plugins from an Activity when no Activity was attached.");
388 }
389 }

◆ detachFromActivityForConfigChanges()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.detachFromActivityForConfigChanges ( )
inline

Call this method from the android.app.Activity that is attached to this
ActivityControlSurfaces
's io.flutter.embedding.engine.FlutterEngine when the android.app.Activity is about to be destroyed due to configuration changes.

This method gives each ActivityAware plugin an opportunity to clean up its references before the is destroyed.

Implements io.flutter.embedding.engine.plugins.activity.ActivityControlSurface.

Definition at line 357 of file FlutterEngineConnectionRegistry.java.

357 {
358 if (isAttachedToActivity()) {
359 try (TraceSection e =
360 TraceSection.scoped(
361 "FlutterEngineConnectionRegistry#detachFromActivityForConfigChanges")) {
362 isWaitingForActivityReattachment = true;
363
364 for (ActivityAware activityAware : activityAwarePlugins.values()) {
365 activityAware.onDetachedFromActivityForConfigChanges();
366 }
367
368 detachFromActivityInternal();
369 }
370 } else {
371 Log.e(TAG, "Attempted to detach plugins from an Activity when no Activity was attached.");
372 }
373 }

◆ detachFromBroadcastReceiver()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.detachFromBroadcastReceiver ( )
inline

Call this method from the BroadcastReceiver that is attached to this
BroadcastReceiverControlSurfaces
's io.flutter.embedding.engine.FlutterEngine when the BroadcastReceiver is about to be destroyed.

This method gives each BroadcastReceiverAware plugin an opportunity to clean up its references before the is destroyed.

Implements io.flutter.embedding.engine.plugins.broadcastreceiver.BroadcastReceiverControlSurface.

Definition at line 582 of file FlutterEngineConnectionRegistry.java.

582 {
583 if (isAttachedToBroadcastReceiver()) {
584 try (TraceSection e =
585 TraceSection.scoped("FlutterEngineConnectionRegistry#detachFromBroadcastReceiver")) {
586 // Notify all BroadcastReceiverAware plugins that they are no longer attached to a
587 // BroadcastReceiver.
588 for (BroadcastReceiverAware broadcastReceiverAware :
589 broadcastReceiverAwarePlugins.values()) {
590 broadcastReceiverAware.onDetachedFromBroadcastReceiver();
591 }
592 }
593 } else {
594 Log.e(
595 TAG,
596 "Attempted to detach plugins from a BroadcastReceiver when no BroadcastReceiver was"
597 + " attached.");
598 }
599 }

◆ detachFromContentProvider()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.detachFromContentProvider ( )
inline

Call this method from the ContentProvider that is attached to this
ContentProviderControlSurfaces
's io.flutter.embedding.engine.FlutterEngine when the ContentProvider is about to be destroyed.

This method gives each ContentProviderAware plugin an opportunity to clean up its references before the is destroyed.

Implements io.flutter.embedding.engine.plugins.contentprovider.ContentProviderControlSurface.

Definition at line 631 of file FlutterEngineConnectionRegistry.java.

631 {
632 if (isAttachedToContentProvider()) {
633 try (TraceSection e =
634 TraceSection.scoped("FlutterEngineConnectionRegistry#detachFromContentProvider")) {
635 // Notify all ContentProviderAware plugins that they are no longer attached to a
636 // ContentProvider.
637 for (ContentProviderAware contentProviderAware : contentProviderAwarePlugins.values()) {
638 contentProviderAware.onDetachedFromContentProvider();
639 }
640 }
641 } else {
642 Log.e(
643 TAG,
644 "Attempted to detach plugins from a ContentProvider when no ContentProvider was"
645 + " attached.");
646 }
647 }

◆ detachFromService()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.detachFromService ( )
inline

Call this method from the Service that is attached to this
ServiceControlSurfaces
's io.flutter.embedding.engine.FlutterEngine when the Service is about to be destroyed.

This method gives each ServiceAware plugin an opportunity to clean up its references before the is destroyed.

Implements io.flutter.embedding.engine.plugins.service.ServiceControlSurface.

Definition at line 516 of file FlutterEngineConnectionRegistry.java.

516 {
517 if (isAttachedToService()) {
518 try (TraceSection e =
519 TraceSection.scoped("FlutterEngineConnectionRegistry#detachFromService")) {
520 // Notify all ServiceAware plugins that they are no longer attached to a Service.
521 for (ServiceAware serviceAware : serviceAwarePlugins.values()) {
522 serviceAware.onDetachedFromService();
523 }
524
525 service = null;
526 servicePluginBinding = null;
527 }
528 } else {
529 Log.e(TAG, "Attempted to detach plugins from a Service when no Service was attached.");
530 }
531 }

◆ get()

FlutterPlugin io.flutter.embedding.engine.FlutterEngineConnectionRegistry.get ( @NonNull Class<? extends FlutterPlugin pluginClass)
inline

Returns the instance of a plugin that is currently attached to the io.flutter.embedding.engine.FlutterEngine associated with this PluginRegistry, which matches the given pluginClass.

If no matching plugin is found, null is returned.

Implements io.flutter.embedding.engine.plugins.PluginRegistry.

Definition at line 212 of file FlutterEngineConnectionRegistry.java.

212 {
213 return plugins.get(pluginClass);
214 }

◆ has()

boolean io.flutter.embedding.engine.FlutterEngineConnectionRegistry.has ( @NonNull Class<? extends FlutterPlugin pluginClass)
inline

Returns true if a plugin of the given type is currently attached to the io.flutter.embedding.engine.FlutterEngine associated with this PluginRegistry.

Implements io.flutter.embedding.engine.plugins.PluginRegistry.

Definition at line 207 of file FlutterEngineConnectionRegistry.java.

207 {
208 return plugins.containsKey(pluginClass);
209 }

◆ onActivityResult()

boolean io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult ( int  requestCode,
int  resultCode,
@Nullable Intent  data 
)
inline

Call this method from the android.app.Activity that is attached to this
ActivityControlSurface
's io.flutter.embedding.engine.FlutterEngine and the associated method in the Activity is invoked.

Returns true if one or more plugins utilized this android.app.Activity result.

Implements io.flutter.embedding.engine.plugins.activity.ActivityControlSurface.

Definition at line 418 of file FlutterEngineConnectionRegistry.java.

418 {
419 if (isAttachedToActivity()) {
420 try (TraceSection e =
421 TraceSection.scoped("FlutterEngineConnectionRegistry#onActivityResult")) {
422 return activityPluginBinding.onActivityResult(requestCode, resultCode, data);
423 }
424 } else {
425 Log.e(
426 TAG,
427 "Attempted to notify ActivityAware plugins of onActivityResult, but no Activity was"
428 + " attached.");
429 return false;
430 }
431 }
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ onMoveToBackground()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onMoveToBackground ( )
inline

Call this method from the Service that is attached to this
ServiceControlSurface
's io.flutter.embedding.engine.FlutterEngine when the Service goes from foreground to background.

Implements io.flutter.embedding.engine.plugins.service.ServiceControlSurface.

Definition at line 544 of file FlutterEngineConnectionRegistry.java.

544 {
545 if (isAttachedToService()) {
546 try (TraceSection e =
547 TraceSection.scoped("FlutterEngineConnectionRegistry#onMoveToBackground")) {
548 servicePluginBinding.onMoveToBackground();
549 }
550 }
551 }

◆ onMoveToForeground()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onMoveToForeground ( )
inline

Call this method from the Service that is attached to this
ServiceControlSurface
's io.flutter.embedding.engine.FlutterEngine when the Service goes from background to foreground.

Implements io.flutter.embedding.engine.plugins.service.ServiceControlSurface.

Definition at line 534 of file FlutterEngineConnectionRegistry.java.

534 {
535 if (isAttachedToService()) {
536 try (TraceSection e =
537 TraceSection.scoped("FlutterEngineConnectionRegistry#onMoveToForeground")) {
538 servicePluginBinding.onMoveToForeground();
539 }
540 }
541 }

◆ onNewIntent()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onNewIntent ( @NonNull Intent  intent)
inline

Call this method from the android.app.Activity that is attached to this
ActivityControlSurface
's io.flutter.embedding.engine.FlutterEngine and the associated method in the Activity is invoked.

Implements io.flutter.embedding.engine.plugins.activity.ActivityControlSurface.

Definition at line 434 of file FlutterEngineConnectionRegistry.java.

434 {
435 if (isAttachedToActivity()) {
436 try (TraceSection e = TraceSection.scoped("FlutterEngineConnectionRegistry#onNewIntent")) {
437 activityPluginBinding.onNewIntent(intent);
438 }
439 } else {
440 Log.e(
441 TAG,
442 "Attempted to notify ActivityAware plugins of onNewIntent, but no Activity was"
443 + " attached.");
444 }
445 }

◆ onRequestPermissionsResult()

boolean io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onRequestPermissionsResult ( int  requestCode,
@NonNull String[]  permissions,
@NonNull int[]  grantResult 
)
inline

Call this method from the android.app.Activity that is attached to this
ActivityControlSurface
's io.flutter.embedding.engine.FlutterEngine and the associated method in the Activity is invoked.

Returns true if one or more plugins utilized this permission result.

Implements io.flutter.embedding.engine.plugins.activity.ActivityControlSurface.

Definition at line 400 of file FlutterEngineConnectionRegistry.java.

401 {
402 if (isAttachedToActivity()) {
403 try (TraceSection e =
404 TraceSection.scoped("FlutterEngineConnectionRegistry#onRequestPermissionsResult")) {
405 return activityPluginBinding.onRequestPermissionsResult(
406 requestCode, permissions, grantResult);
407 }
408 } else {
409 Log.e(
410 TAG,
411 "Attempted to notify ActivityAware plugins of onRequestPermissionsResult, but no Activity"
412 + " was attached.");
413 return false;
414 }
415 }

◆ onRestoreInstanceState()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onRestoreInstanceState ( @Nullable Bundle  bundle)
inline

Call this method from the android.app.Activity or Fragment that is attached to this ActivityControlSurface's io.flutter.embedding.engine.FlutterEngine when android.app.Activity#onCreate(Bundle) or Fragment#onCreate(Bundle) is invoked in the android.app.Activity or Fragment.

Implements io.flutter.embedding.engine.plugins.activity.ActivityControlSurface.

Definition at line 478 of file FlutterEngineConnectionRegistry.java.

478 {
479 if (isAttachedToActivity()) {
480 try (TraceSection e =
481 TraceSection.scoped("FlutterEngineConnectionRegistry#onRestoreInstanceState")) {
482 activityPluginBinding.onRestoreInstanceState(bundle);
483 }
484 } else {
485 Log.e(
486 TAG,
487 "Attempted to notify ActivityAware plugins of onRestoreInstanceState, but no Activity was"
488 + " attached.");
489 }
490 }

◆ onSaveInstanceState()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onSaveInstanceState ( @NonNull Bundle  bundle)
inline

Call this method from the android.app.Activity or Fragment that is attached to this ActivityControlSurface's io.flutter.embedding.engine.FlutterEngine when the associated method is invoked in the android.app.Activity or Fragment.

Implements io.flutter.embedding.engine.plugins.activity.ActivityControlSurface.

Definition at line 463 of file FlutterEngineConnectionRegistry.java.

463 {
464 if (isAttachedToActivity()) {
465 try (TraceSection e =
466 TraceSection.scoped("FlutterEngineConnectionRegistry#onSaveInstanceState")) {
467 activityPluginBinding.onSaveInstanceState(bundle);
468 }
469 } else {
470 Log.e(
471 TAG,
472 "Attempted to notify ActivityAware plugins of onSaveInstanceState, but no Activity was"
473 + " attached.");
474 }
475 }

◆ onUserLeaveHint()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onUserLeaveHint ( )
inline

Call this method from the android.app.Activity that is attached to this
ActivityControlSurface
's io.flutter.embedding.engine.FlutterEngine and the associated method in the Activity is invoked.

Implements io.flutter.embedding.engine.plugins.activity.ActivityControlSurface.

Definition at line 448 of file FlutterEngineConnectionRegistry.java.

448 {
449 if (isAttachedToActivity()) {
450 try (TraceSection e =
451 TraceSection.scoped("FlutterEngineConnectionRegistry#onUserLeaveHint")) {
452 activityPluginBinding.onUserLeaveHint();
453 }
454 } else {
455 Log.e(
456 TAG,
457 "Attempted to notify ActivityAware plugins of onUserLeaveHint, but no Activity was"
458 + " attached.");
459 }
460 }

◆ remove() [1/2]

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.remove ( @NonNull Class<? extends FlutterPlugin pluginClass)
inline

Detaches the plugin of the given type from the io.flutter.embedding.engine.FlutterEngine associated with this PluginRegistry.

If no such plugin exists, this method does nothing.

Implements io.flutter.embedding.engine.plugins.PluginRegistry.

Definition at line 217 of file FlutterEngineConnectionRegistry.java.

217 {
218 FlutterPlugin plugin = plugins.get(pluginClass);
219 if (plugin == null) {
220 return;
221 }
222
223 try (TraceSection e =
224 TraceSection.scoped(
225 "FlutterEngineConnectionRegistry#remove " + pluginClass.getSimpleName())) {
226 // For ActivityAware plugins, notify the plugin that it is detached from
227 // an Activity if an Activity is currently attached to this engine. Then
228 // remove the plugin from our set of ActivityAware plugins.
229 if (plugin instanceof ActivityAware) {
230 if (isAttachedToActivity()) {
231 ActivityAware activityAware = (ActivityAware) plugin;
232 activityAware.onDetachedFromActivity();
233 }
234 activityAwarePlugins.remove(pluginClass);
235 }
236
237 // For ServiceAware plugins, notify the plugin that it is detached from
238 // a Service if a Service is currently attached to this engine. Then
239 // remove the plugin from our set of ServiceAware plugins.
240 if (plugin instanceof ServiceAware) {
241 if (isAttachedToService()) {
242 ServiceAware serviceAware = (ServiceAware) plugin;
243 serviceAware.onDetachedFromService();
244 }
245 serviceAwarePlugins.remove(pluginClass);
246 }
247
248 // For BroadcastReceiverAware plugins, notify the plugin that it is detached from
249 // a BroadcastReceiver if a BroadcastReceiver is currently attached to this engine. Then
250 // remove the plugin from our set of BroadcastReceiverAware plugins.
251 if (plugin instanceof BroadcastReceiverAware) {
252 if (isAttachedToBroadcastReceiver()) {
253 BroadcastReceiverAware broadcastReceiverAware = (BroadcastReceiverAware) plugin;
254 broadcastReceiverAware.onDetachedFromBroadcastReceiver();
255 }
256 broadcastReceiverAwarePlugins.remove(pluginClass);
257 }
258
259 // For ContentProviderAware plugins, notify the plugin that it is detached from
260 // a ContentProvider if a ContentProvider is currently attached to this engine. Then
261 // remove the plugin from our set of ContentProviderAware plugins.
262 if (plugin instanceof ContentProviderAware) {
263 if (isAttachedToContentProvider()) {
264 ContentProviderAware contentProviderAware = (ContentProviderAware) plugin;
265 contentProviderAware.onDetachedFromContentProvider();
266 }
267 contentProviderAwarePlugins.remove(pluginClass);
268 }
269
270 // Notify the plugin that is now detached from this engine. Then remove
271 // it from our set of generic plugins.
272 plugin.onDetachedFromEngine(pluginBinding);
273 plugins.remove(pluginClass);
274 }
275 }

◆ remove() [2/2]

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.remove ( @NonNull Set< Class<? extends FlutterPlugin > >  plugins)
inline

Detaches the plugins of the given types from the io.flutter.embedding.engine.FlutterEngine associated with this PluginRegistry.

If no such plugins exist, this method does nothing.

Implements io.flutter.embedding.engine.plugins.PluginRegistry.

Definition at line 278 of file FlutterEngineConnectionRegistry.java.

278 {
279 for (Class<? extends FlutterPlugin> pluginClass : pluginClasses) {
280 remove(pluginClass);
281 }
282 }

◆ removeAll()

void io.flutter.embedding.engine.FlutterEngineConnectionRegistry.removeAll ( )
inline

Detaches all plugins that are currently attached to the io.flutter.embedding.engine.FlutterEngine associated with this PluginRegistry.

If no plugins are currently attached, this method does nothing.

Implements io.flutter.embedding.engine.plugins.PluginRegistry.

Definition at line 285 of file FlutterEngineConnectionRegistry.java.

285 {
286 // We copy the keys to a new set so that we can mutate the set while using
287 // the keys.
288 remove(new HashSet<>(plugins.keySet()));
289 plugins.clear();
290 }

The documentation for this class was generated from the following file: