Interface ServiceControlSurface
public interface ServiceControlSurface
Control surface through which a
Service attaches to a FlutterEngine.
A Service that contains a FlutterEngine should
coordinate itself with the FlutterEngine's
ServiceControlSurface.
-
Method Summary
Modifier and TypeMethodDescriptionvoidattachToService(Service service, androidx.lifecycle.Lifecycle lifecycle, boolean isForeground) Call this method from theServicethat is running theFlutterEnginethat is associated with thisServiceControlSurface.voidCall this method from theServicethat is attached to thisServiceControlSurfaces'sFlutterEnginewhen theServiceis about to be destroyed.voidCall this method from theServicethat is attached to thisServiceControlSurface'sFlutterEnginewhen theServicegoes from foreground to background.voidCall this method from theServicethat is attached to thisServiceControlSurface'sFlutterEnginewhen theServicegoes from background to foreground.
-
Method Details
-
attachToService
void attachToService(@NonNull Service service, @Nullable androidx.lifecycle.Lifecycle lifecycle, boolean isForeground) Call this method from theServicethat is running theFlutterEnginethat is associated with thisServiceControlSurface.Once a
Serviceis created, and its associatedFlutterEngineis executing Dart code, theServiceshould invoke this method. At that point theFlutterEngineis considered "attached" to theServiceand allServiceAwareplugins are given access to theService.isForegroundshould be true if the givenServiceis running in the foreground, false otherwise. -
detachFromService
void detachFromService()Call this method from theServicethat is attached to thisServiceControlSurfaces'sFlutterEnginewhen theServiceis about to be destroyed.This method gives each
ServiceAwareplugin an opportunity to clean up its references before theis destroyed. -
onMoveToForeground
void onMoveToForeground()Call this method from theServicethat is attached to thisServiceControlSurface'sFlutterEnginewhen theServicegoes from background to foreground. -
onMoveToBackground
void onMoveToBackground()Call this method from theServicethat is attached to thisServiceControlSurface'sFlutterEnginewhen theServicegoes from foreground to background.
-