Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ServicePluginBinding.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;
10
11/** Binding that gives {@link ServiceAware} plugins access to an associated {@link Service}. */
12public interface ServicePluginBinding {
13
14 /**
15 * Returns the {@link Service} that is currently attached to the {@link
16 * io.flutter.embedding.engine.FlutterEngine} that owns this {@code ServicePluginBinding}.
17 */
18 @NonNull
19 Service getService();
20
21 /**
22 * Returns the {@code Lifecycle} associated with the attached {@code Service}.
23 *
24 * <p>Use the flutter_plugin_android_lifecycle plugin to turn the returned {@code Object} into a
25 * {@code Lifecycle} object. See
26 * (https://github.com/flutter/plugins/tree/master/packages/flutter_plugin_android_lifecycle).
27 * Flutter plugins that rely on {@code Lifecycle} are forced to use the
28 * flutter_plugin_android_lifecycle plugin so that the version of the Android Lifecycle library is
29 * exposed to pub, which allows Flutter to manage different versions library over time.
30 */
31 @Nullable
32 Object getLifecycle();
33
34 /**
35 * Adds the given {@code listener} to be notified when the associated {@link Service} goes from
36 * background to foreground, or foreground to background.
37 */
39
40 /**
41 * Removes the given {@code listener}, which was previously added with {@link
42 * #addOnModeChangeListener(ServiceAware.OnModeChangeListener)}.
43 */
45}
void removeOnModeChangeListener(@NonNull ServiceAware.OnModeChangeListener listener)
void addOnModeChangeListener(@NonNull ServiceAware.OnModeChangeListener listener)