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 TypeMethodDescriptionvoid
attachToService
(Service service, androidx.lifecycle.Lifecycle lifecycle, boolean isForeground) Call this method from theService
that is running theFlutterEngine
that is associated with thisServiceControlSurface
.void
Call this method from theService
that is attached to thisServiceControlSurfaces
'sFlutterEngine
when theService
is about to be destroyed.void
Call this method from theService
that is attached to thisServiceControlSurface
'sFlutterEngine
when theService
goes from foreground to background.void
Call this method from theService
that is attached to thisServiceControlSurface
'sFlutterEngine
when theService
goes from background to foreground.
-
Method Details
-
attachToService
void attachToService(@NonNull Service service, @Nullable androidx.lifecycle.Lifecycle lifecycle, boolean isForeground) Call this method from theService
that is running theFlutterEngine
that is associated with thisServiceControlSurface
.Once a
Service
is created, and its associatedFlutterEngine
is executing Dart code, theService
should invoke this method. At that point theFlutterEngine
is considered "attached" to theService
and allServiceAware
plugins are given access to theService
.isForeground
should be true if the givenService
is running in the foreground, false otherwise. -
detachFromService
void detachFromService()Call this method from theService
that is attached to thisServiceControlSurfaces
'sFlutterEngine
when theService
is about to be destroyed.This method gives each
ServiceAware
plugin an opportunity to clean up its references before theis destroyed
. -
onMoveToForeground
void onMoveToForeground()Call this method from theService
that is attached to thisServiceControlSurface
'sFlutterEngine
when theService
goes from background to foreground. -
onMoveToBackground
void onMoveToBackground()Call this method from theService
that is attached to thisServiceControlSurface
'sFlutterEngine
when theService
goes from foreground to background.
-