Flutter Engine
The Flutter Engine
ActivityPluginBinding.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 android.app.Activity;
8import android.os.Bundle;
9import androidx.annotation.NonNull;
10import androidx.annotation.Nullable;
11import io.flutter.plugin.common.PluginRegistry;
12
13/**
14 * Binding that gives {@link ActivityAware} plugins access to an associated {@link
15 * android.app.Activity} and the {@link android.app.Activity}'s lifecycle methods.
16 *
17 * <p>To obtain an instance of an {@code ActivityPluginBinding} in a Flutter plugin, implement the
18 * {@link ActivityAware} interface. A binding is provided in {@link
19 * ActivityAware#onAttachedToActivity(ActivityPluginBinding)} and {@link
20 * ActivityAware#onReattachedToActivityForConfigChanges(ActivityPluginBinding)}.
21 */
22public interface ActivityPluginBinding {
23
24 /**
25 * Returns the {@link android.app.Activity} that is currently attached to the {@link
26 * io.flutter.embedding.engine.FlutterEngine} that owns this {@code ActivityPluginBinding}.
27 */
28 @NonNull
29 Activity getActivity();
30
31 /**
32 * Returns the {@code Lifecycle} associated with the attached {@code Activity}.
33 *
34 * <p>Use the flutter_plugin_android_lifecycle plugin to turn the returned {@code Object} into a
35 * {@code Lifecycle} object. See
36 * (https://github.com/flutter/plugins/tree/master/packages/flutter_plugin_android_lifecycle).
37 * Flutter plugins that rely on {@code Lifecycle} are forced to use the
38 * flutter_plugin_android_lifecycle plugin so that the version of the Android Lifecycle library is
39 * exposed to pub, which allows Flutter to manage different versions library over time.
40 */
41 @NonNull
42 Object getLifecycle();
43
44 /**
45 * Adds a listener that is invoked whenever the associated {@link android.app.Activity}'s {@code
46 * onRequestPermissionsResult(...)} method is invoked.
47 */
50
51 /**
52 * Removes a listener that was added in {@link
53 * #addRequestPermissionsResultListener(PluginRegistry.RequestPermissionsResultListener)}.
54 */
57
58 /**
59 * Adds a listener that is invoked whenever the associated {@link android.app.Activity}'s {@code
60 * onActivityResult(...)} method is invoked.
61 */
63
64 /**
65 * Removes a listener that was added in {@link
66 * #addActivityResultListener(PluginRegistry.ActivityResultListener)}.
67 */
69
70 /**
71 * Adds a listener that is invoked whenever the associated {@link android.app.Activity}'s {@code
72 * onNewIntent(...)} method is invoked.
73 */
75
76 /**
77 * Removes a listener that was added in {@link
78 * #addOnNewIntentListener(PluginRegistry.NewIntentListener)}.
79 */
81
82 /**
83 * Adds a listener that is invoked whenever the associated {@link android.app.Activity}'s {@code
84 * onUserLeaveHint()} method is invoked.
85 */
87
88 /**
89 * Removes a listener that was added in {@link
90 * #addOnUserLeaveHintListener(PluginRegistry.UserLeaveHintListener)}.
91 */
93
94 /**
95 * Adds a listener that is invoked whenever the associated {@link android.app.Activity}'s {@code
96 * onWindowFocusChanged()} method is invoked.
97 */
99
100 /**
101 * Removes a listener that was added in {@link
102 * #addOnWindowFocusChangedListener(PluginRegistry.WindowFocusChangedListener)}.
103 */
106
107 /**
108 * Adds a listener that is invoked when the associated {@code Activity} or {@code Fragment} saves
109 * and restores instance state.
110 */
112
113 /**
114 * Removes a listener that was added in {@link
115 * #addOnSaveStateListener(OnSaveInstanceStateListener)}.
116 */
118
120 /**
121 * Invoked when the associated {@code Activity} or {@code Fragment} executes {@link
122 * Activity#onSaveInstanceState(Bundle)}.
123 */
124 void onSaveInstanceState(@NonNull Bundle bundle);
125
126 /**
127 * Invoked when the associated {@code Activity} executes {@link
128 * android.app.Activity#onCreate(Bundle)} or associated {@code Fragment} executes {@code
129 * Fragment#onCreate(Bundle)}.
130 */
131 void onRestoreInstanceState(@Nullable Bundle bundle);
132 }
133}
void removeOnUserLeaveHintListener(@NonNull PluginRegistry.UserLeaveHintListener listener)
void addActivityResultListener(@NonNull PluginRegistry.ActivityResultListener listener)
void addOnWindowFocusChangedListener(@NonNull PluginRegistry.WindowFocusChangedListener listener)
void addOnNewIntentListener(@NonNull PluginRegistry.NewIntentListener listener)
void removeActivityResultListener(@NonNull PluginRegistry.ActivityResultListener listener)
void addOnSaveStateListener(@NonNull OnSaveInstanceStateListener listener)
void addOnUserLeaveHintListener(@NonNull PluginRegistry.UserLeaveHintListener listener)
void removeOnSaveStateListener(@NonNull OnSaveInstanceStateListener listener)
void addRequestPermissionsResultListener( @NonNull PluginRegistry.RequestPermissionsResultListener listener)
void removeRequestPermissionsResultListener( @NonNull PluginRegistry.RequestPermissionsResultListener listener)
void removeOnWindowFocusChangedListener( @NonNull PluginRegistry.WindowFocusChangedListener listener)
void removeOnNewIntentListener(@NonNull PluginRegistry.NewIntentListener listener)