Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ServiceControlSurface.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter.embedding.engine.plugins.service;
6
7import android.app.Service;
8import androidx.annotation.NonNull;
9import androidx.annotation.Nullable;
10import androidx.lifecycle.Lifecycle;
11
12/**
13 * Control surface through which a {@link Service} attaches to a {@link
14 * io.flutter.embedding.engine.FlutterEngine}.
15 *
16 * <p>A {@link Service} that contains a {@link io.flutter.embedding.engine.FlutterEngine} should
17 * coordinate itself with the {@link io.flutter.embedding.engine.FlutterEngine}'s {@code
18 * ServiceControlSurface}.
19 */
20public interface ServiceControlSurface {
21 /**
22 * Call this method from the {@link Service} that is running the {@link
23 * io.flutter.embedding.engine.FlutterEngine} that is associated with this {@code
24 * ServiceControlSurface}.
25 *
26 * <p>Once a {@link Service} is created, and its associated {@link
27 * io.flutter.embedding.engine.FlutterEngine} is executing Dart code, the {@link Service} should
28 * invoke this method. At that point the {@link io.flutter.embedding.engine.FlutterEngine} is
29 * considered "attached" to the {@link Service} and all {@link ServiceAware} plugins are given
30 * access to the {@link Service}.
31 *
32 * <p>{@code isForeground} should be true if the given {@link Service} is running in the
33 * foreground, false otherwise.
34 */
36 @NonNull Service service, @Nullable Lifecycle lifecycle, boolean isForeground);
37
38 /**
39 * Call this method from the {@link Service} that is attached to this {@code
40 * ServiceControlSurfaces}'s {@link io.flutter.embedding.engine.FlutterEngine} when the {@link
41 * Service} is about to be destroyed.
42 *
43 * <p>This method gives each {@link ServiceAware} plugin an opportunity to clean up its references
44 * before the {@link Service is destroyed}.
45 */
47
48 /**
49 * Call this method from the {@link Service} that is attached to this {@code
50 * ServiceControlSurface}'s {@link io.flutter.embedding.engine.FlutterEngine} when the {@link
51 * Service} goes from background to foreground.
52 */
54
55 /**
56 * Call this method from the {@link Service} that is attached to this {@code
57 * ServiceControlSurface}'s {@link io.flutter.embedding.engine.FlutterEngine} when the {@link
58 * Service} goes from foreground to background.
59 */
61}
void attachToService( @NonNull Service service, @Nullable Lifecycle lifecycle, boolean isForeground)