Flutter Engine
The Flutter Engine
ActivityControlSurface.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.content.Intent;
9import android.os.Bundle;
10import androidx.annotation.NonNull;
11import androidx.annotation.Nullable;
12import androidx.lifecycle.Lifecycle;
13import io.flutter.embedding.android.ExclusiveAppComponent;
14
15/**
16 * Control surface through which an {@link android.app.Activity} attaches to a {@link
17 * io.flutter.embedding.engine.FlutterEngine}.
18 *
19 * <p>An {@link android.app.Activity} that contains a {@link
20 * io.flutter.embedding.android.FlutterView} and associated {@link
21 * io.flutter.embedding.engine.FlutterEngine} should coordinate itself with the {@link
22 * io.flutter.embedding.engine.FlutterEngine}'s {@code ActivityControlSurface}.
23 *
24 * <ol>
25 * <li>Once an {@link android.app.Activity} is created, and its associated {@link
26 * io.flutter.embedding.engine.FlutterEngine} is executing Dart code, the {@link
27 * android.app.Activity} should invoke {@link #attachToActivity( ExclusiveAppComponent,
28 * Lifecycle)}. At this point the {@link io.flutter.embedding.engine.FlutterEngine} is
29 * considered "attached" to the {@link android.app.Activity} and all {@link ActivityAware}
30 * plugins are given access to the {@link android.app.Activity}.
31 * <li>Just before an attached {@link android.app.Activity} is destroyed for configuration change
32 * purposes, that {@link android.app.Activity} should invoke {@link
33 * #detachFromActivityForConfigChanges()}, giving each {@link ActivityAware} plugin an
34 * opportunity to clean up its references before the {@link android.app.Activity is
35 * destroyed}.
36 * <li>When an {@link android.app.Activity} is destroyed for non-configuration-change purposes, or
37 * when the {@link android.app.Activity} is no longer interested in displaying a {@link
38 * io.flutter.embedding.engine.FlutterEngine}'s content, the {@link android.app.Activity}
39 * should invoke {@link #detachFromActivity()}.
40 * <li>When a {@link android.app.Activity} is being attached while an existing {@link
41 * ExclusiveAppComponent} is already attached, the existing {@link ExclusiveAppComponent} is
42 * given a chance to detach first via {@link ExclusiveAppComponent#detachFromFlutterEngine()}
43 * before the new activity attaches.
44 * </ol>
45 *
46 * The attached {@link android.app.Activity} should also forward all {@link android.app.Activity}
47 * calls that this {@code ActivityControlSurface} supports, e.g., {@link
48 * #onRequestPermissionsResult(int, String[], int[])}. These forwarded calls are made available to
49 * all {@link ActivityAware} plugins that are added to the attached {@link
50 * io.flutter.embedding.engine.FlutterEngine}.
51 */
52public interface ActivityControlSurface {
53 /**
54 * Call this method from the {@link ExclusiveAppComponent} that is displaying the visual content
55 * of the {@link io.flutter.embedding.engine.FlutterEngine} that is associated with this {@code
56 * ActivityControlSurface}.
57 *
58 * <p>Once an {@link ExclusiveAppComponent} is created, and its associated {@link
59 * io.flutter.embedding.engine.FlutterEngine} is executing Dart code, the {@link
60 * ExclusiveAppComponent} should invoke this method. At that point the {@link
61 * io.flutter.embedding.engine.FlutterEngine} is considered "attached" to the {@link
62 * ExclusiveAppComponent} and all {@link ActivityAware} plugins are given access to the {@link
63 * ExclusiveAppComponent}'s {@link android.app.Activity}.
64 */
66 @NonNull ExclusiveAppComponent<Activity> exclusiveActivity, @NonNull Lifecycle lifecycle);
67
68 /**
69 * Call this method from the {@link android.app.Activity} that is attached to this {@code
70 * ActivityControlSurfaces}'s {@link io.flutter.embedding.engine.FlutterEngine} when the {@link
71 * android.app.Activity} is about to be destroyed due to configuration changes.
72 *
73 * <p>This method gives each {@link ActivityAware} plugin an opportunity to clean up its
74 * references before the {@link android.app.Activity is destroyed}.
75 */
77
78 /**
79 * Call this method from the {@link android.app.Activity} that is attached to this {@code
80 * ActivityControlSurfaces}'s {@link io.flutter.embedding.engine.FlutterEngine} when the {@link
81 * android.app.Activity} is about to be destroyed for non-configuration-change reasons.
82 *
83 * <p>This method gives each {@link ActivityAware} plugin an opportunity to clean up its
84 * references before the {@link android.app.Activity is destroyed}.
85 */
87
88 /**
89 * Call this method from the {@link android.app.Activity} that is attached to this {@code
90 * ActivityControlSurface}'s {@link io.flutter.embedding.engine.FlutterEngine} and the associated
91 * method in the {@link Activity} is invoked.
92 *
93 * <p>Returns true if one or more plugins utilized this permission result.
94 */
96 int requestCode, @NonNull String[] permissions, @NonNull int[] grantResult);
97
98 /**
99 * Call this method from the {@link android.app.Activity} that is attached to this {@code
100 * ActivityControlSurface}'s {@link io.flutter.embedding.engine.FlutterEngine} and the associated
101 * method in the {@link Activity} is invoked.
102 *
103 * <p>Returns true if one or more plugins utilized this {@link android.app.Activity} result.
104 */
105 boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data);
106
107 /**
108 * Call this method from the {@link android.app.Activity} that is attached to this {@code
109 * ActivityControlSurface}'s {@link io.flutter.embedding.engine.FlutterEngine} and the associated
110 * method in the {@link Activity} is invoked.
111 */
112 void onNewIntent(@NonNull Intent intent);
113
114 /**
115 * Call this method from the {@link android.app.Activity} that is attached to this {@code
116 * ActivityControlSurface}'s {@link io.flutter.embedding.engine.FlutterEngine} and the associated
117 * method in the {@link Activity} is invoked.
118 */
120
121 /**
122 * Call this method from the {@link android.app.Activity} or {@code Fragment} that is attached to
123 * this {@code ActivityControlSurface}'s {@link io.flutter.embedding.engine.FlutterEngine} when
124 * the associated method is invoked in the {@link android.app.Activity} or {@code Fragment}.
125 */
126 void onSaveInstanceState(@NonNull Bundle bundle);
127
128 /**
129 * Call this method from the {@link android.app.Activity} or {@code Fragment} that is attached to
130 * this {@code ActivityControlSurface}'s {@link io.flutter.embedding.engine.FlutterEngine} when
131 * {@link android.app.Activity#onCreate(Bundle)} or {@code Fragment#onCreate(Bundle)} is invoked
132 * in the {@link android.app.Activity} or {@code Fragment}.
133 */
134 void onRestoreInstanceState(@Nullable Bundle bundle);
135}
boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
void attachToActivity( @NonNull ExclusiveAppComponent< Activity > exclusiveActivity, @NonNull Lifecycle lifecycle)
boolean onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResult)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63