public interface ServiceControlSurface
Service
attaches to a FlutterEngine
.
A Service
that contains a FlutterEngine
should
coordinate itself with the FlutterEngine
's ServiceControlSurface
.
Modifier and Type | Method and Description |
---|---|
void |
attachToService(Service service,
androidx.lifecycle.Lifecycle lifecycle,
boolean isForeground)
Call this method from the
Service that is running the FlutterEngine that is associated with this ServiceControlSurface . |
void |
detachFromService()
Call this method from the
Service that is attached to this ServiceControlSurfaces 's FlutterEngine when the Service is about to be destroyed. |
void |
onMoveToBackground()
Call this method from the
Service that is attached to this ServiceControlSurface 's FlutterEngine when the Service goes from foreground to background. |
void |
onMoveToForeground()
Call this method from the
Service that is attached to this ServiceControlSurface 's FlutterEngine when the Service goes from background to foreground. |
void attachToService(@NonNull Service service, @Nullable androidx.lifecycle.Lifecycle lifecycle, boolean isForeground)
Service
that is running the FlutterEngine
that is associated with this ServiceControlSurface
.
Once a Service
is created, and its associated FlutterEngine
is executing Dart code, the Service
should
invoke this method. At that point the 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.
void detachFromService()
Service
that is attached to this ServiceControlSurfaces
's 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
.
void onMoveToForeground()
Service
that is attached to this ServiceControlSurface
's FlutterEngine
when the Service
goes from background to foreground.void onMoveToBackground()
Service
that is attached to this ServiceControlSurface
's FlutterEngine
when the Service
goes from foreground to background.