Flutter Engine
The Flutter Engine
FlutterFragmentActivity.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.app;
6
7import android.content.Context;
8import android.content.Intent;
9import android.content.res.Configuration;
10import android.os.Bundle;
11import androidx.fragment.app.FragmentActivity;
12import io.flutter.app.FlutterActivityDelegate.ViewFactory;
13import io.flutter.plugin.common.PluginRegistry;
14import io.flutter.view.FlutterNativeView;
15import io.flutter.view.FlutterView;
16
17/**
18 * Deprecated class for activities that use Flutter who also require the use of the Android v4
19 * Support library's {@link FragmentActivity}.
20 *
21 * <p>Applications that don't have this need will likely want to use {@link FlutterActivity}
22 * instead.
23 *
24 * <p><strong>Important!</strong> Flutter does not bundle the necessary Android v4 Support library
25 * classes for this class to work at runtime. It is the responsibility of the app developer using
26 * this class to ensure that they link against the v4 support library .jar file when creating their
27 * app to ensure that {@link FragmentActivity} is available at runtime.
28 *
29 * @see <a target="_new"
30 * href="https://developer.android.com/training/testing/set-up-project">https://developer.android.com/training/testing/set-up-project</a>
31 * @deprecated this class is replaced by {@link
32 * io.flutter.embedding.android.FlutterFragmentActivity}.
33 */
34@Deprecated
35public class FlutterFragmentActivity extends FragmentActivity
36 implements FlutterView.Provider, PluginRegistry, ViewFactory {
37 private final FlutterActivityDelegate delegate = new FlutterActivityDelegate(this, this);
38
39 // These aliases ensure that the methods we forward to the delegate adhere
40 // to relevant interfaces versus just existing in FlutterActivityDelegate.
41 private final FlutterActivityEvents eventDelegate = delegate;
42 private final FlutterView.Provider viewProvider = delegate;
43 private final PluginRegistry pluginRegistry = delegate;
44
45 /**
46 * Returns the Flutter view used by this activity; will be null before {@link #onCreate(Bundle)}
47 * is called.
48 */
49 @Override
51 return viewProvider.getFlutterView();
52 }
53
54 /**
55 * Hook for subclasses to customize the creation of the {@code FlutterView}.
56 *
57 * <p>The default implementation returns {@code null}, which will cause the activity to use a
58 * newly instantiated full-screen view.
59 */
60 @Override
61 public FlutterView createFlutterView(Context context) {
62 return null;
63 }
64
65 @Override
67 return null;
68 }
69
70 @Override
71 public boolean retainFlutterNativeView() {
72 return false;
73 }
74
75 @Override
76 public final boolean hasPlugin(String key) {
77 return pluginRegistry.hasPlugin(key);
78 }
79
80 @Override
81 public final <T> T valuePublishedByPlugin(String pluginKey) {
82 return pluginRegistry.valuePublishedByPlugin(pluginKey);
83 }
84
85 @Override
86 public final Registrar registrarFor(String pluginKey) {
87 return pluginRegistry.registrarFor(pluginKey);
88 }
89
90 @Override
91 protected void onCreate(Bundle savedInstanceState) {
92 super.onCreate(savedInstanceState);
93 eventDelegate.onCreate(savedInstanceState);
94 }
95
96 @Override
97 protected void onDestroy() {
98 eventDelegate.onDestroy();
99 super.onDestroy();
100 }
101
102 @Override
103 public void onBackPressed() {
104 if (!eventDelegate.onBackPressed()) {
105 super.onBackPressed();
106 }
107 }
108
109 @Override
110 protected void onStart() {
111 super.onStart();
112 eventDelegate.onStart();
113 }
114
115 @Override
116 protected void onStop() {
117 eventDelegate.onStop();
118 super.onStop();
119 }
120
121 @Override
122 protected void onPause() {
123 super.onPause();
124 eventDelegate.onPause();
125 }
126
127 @Override
128 protected void onPostResume() {
129 super.onPostResume();
130 eventDelegate.onPostResume();
131 }
132
133 @Override
135 int requestCode, String[] permissions, int[] grantResults) {
136 super.onRequestPermissionsResult(requestCode, permissions, grantResults);
137 eventDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
138 }
139
140 @Override
141 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
142 if (!eventDelegate.onActivityResult(requestCode, resultCode, data)) {
143 super.onActivityResult(requestCode, resultCode, data);
144 }
145 }
146
147 @Override
148 protected void onNewIntent(Intent intent) {
149 super.onNewIntent(intent);
150 eventDelegate.onNewIntent(intent);
151 }
152
153 @Override
154 @SuppressWarnings("MissingSuperCall")
155 public void onUserLeaveHint() {
156 eventDelegate.onUserLeaveHint();
157 }
158
159 @Override
160 public void onWindowFocusChanged(boolean hasFocus) {
161 super.onWindowFocusChanged(hasFocus);
162 eventDelegate.onWindowFocusChanged(hasFocus);
163 }
164
165 @Override
166 public void onTrimMemory(int level) {
167 super.onTrimMemory(level);
168 eventDelegate.onTrimMemory(level);
169 }
170
171 @Override
172 public void onLowMemory() {
173 eventDelegate.onLowMemory();
174 }
175
176 @Override
177 public void onConfigurationChanged(Configuration newConfig) {
178 super.onConfigurationChanged(newConfig);
179 eventDelegate.onConfigurationChanged(newConfig);
180 }
181}
final< T > T valuePublishedByPlugin(String pluginKey)
void onActivityResult(int requestCode, int resultCode, Intent data)
void onCreate(Bundle savedInstanceState)
FlutterView createFlutterView(Context context)
void onConfigurationChanged(Configuration newConfig)
void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
final Registrar registrarFor(String pluginKey)
void onWindowFocusChanged(boolean hasFocus)
void onCreate(Bundle savedInstanceState)
boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
boolean onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
boolean hasPlugin(@NonNull String pluginKey)
< T > T valuePublishedByPlugin(@NonNull String pluginKey)
Registrar registrarFor(@NonNull String pluginKey)
#define T
Definition: precompiler.cc:65
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63