Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ActivityAware.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.activity;
6
7import androidx.annotation.NonNull;
8
9/**
10 * {@link io.flutter.embedding.engine.plugins.FlutterPlugin} that is interested in {@link
11 * android.app.Activity} lifecycle events related to a {@link
12 * io.flutter.embedding.engine.FlutterEngine} running within the given {@link android.app.Activity}.
13 */
14public interface ActivityAware {
15 /**
16 * This {@code ActivityAware} {@link io.flutter.embedding.engine.plugins.FlutterPlugin} is now
17 * associated with an {@link android.app.Activity}.
18 *
19 * <p>This method can be invoked in 1 of 2 situations:
20 *
21 * <ul>
22 * <li>This {@code ActivityAware} {@link io.flutter.embedding.engine.plugins.FlutterPlugin} was
23 * just added to a {@link io.flutter.embedding.engine.FlutterEngine} that was already
24 * connected to a running {@link android.app.Activity}.
25 * <li>This {@code ActivityAware} {@link io.flutter.embedding.engine.plugins.FlutterPlugin} was
26 * already added to a {@link io.flutter.embedding.engine.FlutterEngine} and that {@link
27 * io.flutter.embedding.engine.FlutterEngine} was just connected to an {@link
28 * android.app.Activity}.
29 * </ul>
30 *
31 * The given {@link ActivityPluginBinding} contains {@link android.app.Activity}-related
32 * references that an {@code ActivityAware} {@link
33 * io.flutter.embedding.engine.plugins.FlutterPlugin} may require, such as a reference to the
34 * actual {@link android.app.Activity} in question. The {@link ActivityPluginBinding} may be
35 * referenced until either {@link #onDetachedFromActivityForConfigChanges()} or {@link
36 * #onDetachedFromActivity()} is invoked. At the conclusion of either of those methods, the
37 * binding is no longer valid. Clear any references to the binding or its resources, and do not
38 * invoke any further methods on the binding or its resources.
39 */
41
42 /**
43 * The {@link android.app.Activity} that was attached and made available in {@link
44 * #onAttachedToActivity(ActivityPluginBinding)} has been detached from this {@code
45 * ActivityAware}'s {@link io.flutter.embedding.engine.FlutterEngine} for the purpose of
46 * processing a configuration change.
47 *
48 * <p>By the end of this method, the {@link android.app.Activity} that was made available in
49 * {@link #onAttachedToActivity(ActivityPluginBinding)} is no longer valid. Any references to the
50 * associated {@link android.app.Activity} or {@link ActivityPluginBinding} should be cleared.
51 *
52 * <p>This method should be quickly followed by {@link
53 * #onReattachedToActivityForConfigChanges(ActivityPluginBinding)}, which signifies that a new
54 * {@link android.app.Activity} has been created with the new configuration options. That method
55 * provides a new {@link ActivityPluginBinding}, which references the newly created and associated
56 * {@link android.app.Activity}.
57 *
58 * <p>Any {@code Lifecycle} listeners that were registered in {@link
59 * #onAttachedToActivity(ActivityPluginBinding)} should be deregistered here to avoid a possible
60 * memory leak and other side effects.
61 */
63
64 /**
65 * This plugin and its {@link io.flutter.embedding.engine.FlutterEngine} have been re-attached to
66 * an {@link android.app.Activity} after the {@link android.app.Activity} was recreated to handle
67 * configuration changes.
68 *
69 * <p>{@code binding} includes a reference to the new instance of the {@link
70 * android.app.Activity}. {@code binding} and its references may be cached and used from now until
71 * either {@link #onDetachedFromActivityForConfigChanges()} or {@link #onDetachedFromActivity()}
72 * is invoked. At the conclusion of either of those methods, the binding is no longer valid. Clear
73 * any references to the binding or its resources, and do not invoke any further methods on the
74 * binding or its resources.
75 */
77
78 /**
79 * This plugin has been detached from an {@link android.app.Activity}.
80 *
81 * <p>Detachment can occur for a number of reasons.
82 *
83 * <ul>
84 * <li>The app is no longer visible and the {@link android.app.Activity} instance has been
85 * destroyed.
86 * <li>The {@link io.flutter.embedding.engine.FlutterEngine} that this plugin is connected to
87 * has been detached from its {@link io.flutter.embedding.android.FlutterView}.
88 * <li>This {@code ActivityAware} plugin has been removed from its {@link
89 * io.flutter.embedding.engine.FlutterEngine}.
90 * </ul>
91 *
92 * By the end of this method, the {@link android.app.Activity} that was made available in {@link
93 * #onAttachedToActivity(ActivityPluginBinding)} is no longer valid. Any references to the
94 * associated {@link android.app.Activity} or {@link ActivityPluginBinding} should be cleared.
95 *
96 * <p>Any {@code Lifecycle} listeners that were registered in {@link
97 * #onAttachedToActivity(ActivityPluginBinding)} or {@link
98 * #onReattachedToActivityForConfigChanges(ActivityPluginBinding)} should be deregistered here to
99 * avoid a possible memory leak and other side effects.
100 */
102}
void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding)
void onAttachedToActivity(@NonNull ActivityPluginBinding binding)