Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Package Functions | List of all members
io.flutter.app.FlutterActivityDelegate Class Reference
Inheritance diagram for io.flutter.app.FlutterActivityDelegate:
io.flutter.app.FlutterActivityEvents

Classes

interface  ViewFactory
 

Public Member Functions

 FlutterActivityDelegate (Activity activity, ViewFactory viewFactory)
 
FlutterView getFlutterView ()
 
boolean hasPlugin (String key)
 
Registrar registrarFor (String pluginKey)
 
boolean onRequestPermissionsResult (int requestCode, String[] permissions, int[] grantResults)
 
boolean onActivityResult (int requestCode, int resultCode, Intent data)
 
void onCreate (Bundle savedInstanceState)
 
void onNewIntent (Intent intent)
 
void onPause ()
 
void onStart ()
 
void onResume ()
 
void onStop ()
 
void onPostResume ()
 
void onDestroy ()
 
boolean onBackPressed ()
 
void onUserLeaveHint ()
 
void onWindowFocusChanged (boolean hasFocus)
 
void onTrimMemory (int level)
 
void onLowMemory ()
 
void onConfigurationChanged (Configuration newConfig)
 

Package Functions

public< T > T valuePublishedByPlugin (String pluginKey)
 

Detailed Description

Deprecated class that performs the actual work of tying Android android.app.Activity instances to Flutter.

This exists as a dedicated class (as opposed to being integrated directly into FlutterActivity) to facilitate applications that don't wish to subclass FlutterActivity. The most obvious example of when this may come in handy is if an application wishes to subclass the Android v4 support library's FragmentActivity.

Usage:

To wire this class up to your activity, simply forward the events defined in FlutterActivityEvents from your activity to an instance of this class. Optionally, you can make your activity implement PluginRegistry and/or io.flutter.view.FlutterView.Provider and forward those methods to this class as well.

Deprecated:
io.flutter.embedding.android.FlutterActivity is the new API that now replaces this class and io.flutter.app.FlutterActivity. See https://flutter.dev/go/android-project-migration for more migration details.

Definition at line 57 of file FlutterActivityDelegate.java.

Constructor & Destructor Documentation

◆ FlutterActivityDelegate()

io.flutter.app.FlutterActivityDelegate.FlutterActivityDelegate ( Activity  activity,
ViewFactory  viewFactory 
)
inline

Definition at line 97 of file FlutterActivityDelegate.java.

97 {
98 this.activity = Preconditions.checkNotNull(activity);
99 this.viewFactory = Preconditions.checkNotNull(viewFactory);
100 }

Member Function Documentation

◆ getFlutterView()

FlutterView io.flutter.app.FlutterActivityDelegate.getFlutterView ( )
inline

Definition at line 103 of file FlutterActivityDelegate.java.

103 {
104 return flutterView;
105 }

◆ hasPlugin()

boolean io.flutter.app.FlutterActivityDelegate.hasPlugin ( String  key)
inline

Definition at line 109 of file FlutterActivityDelegate.java.

109 {
110 return flutterView.getPluginRegistry().hasPlugin(key);
111 }

◆ onActivityResult()

boolean io.flutter.app.FlutterActivityDelegate.onActivityResult ( int  requestCode,
int  resultCode,
Intent  data 
)
inline

Definition at line 133 of file FlutterActivityDelegate.java.

133 {
134 return flutterView.getPluginRegistry().onActivityResult(requestCode, resultCode, data);
135 }

◆ onBackPressed()

boolean io.flutter.app.FlutterActivityDelegate.onBackPressed ( )
inline

Invoked when the activity has detected the user's press of the back key.

Returns
true if the listener handled the event; false to let the activity continue with its default back button handling.
See also
android.app.Activity::onBackPressed()

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 247 of file FlutterActivityDelegate.java.

247 {
248 if (flutterView != null) {
249 flutterView.popRoute();
250 return true;
251 }
252 return false;
253 }

◆ onConfigurationChanged()

void io.flutter.app.FlutterActivityDelegate.onConfigurationChanged ( Configuration  newConfig)
inline

Definition at line 280 of file FlutterActivityDelegate.java.

280{}

◆ onCreate()

void io.flutter.app.FlutterActivityDelegate.onCreate ( Bundle  savedInstanceState)
inline
Parameters
savedInstanceStateIf the activity is being re-initialized after previously being shut down then this Bundle contains the data it most recently supplied in
onSaveInstanceState(Bundle)
.
See also
android.app.Activity::onCreate(android.os.Bundle)

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 138 of file FlutterActivityDelegate.java.

138 {
139 Window window = activity.getWindow();
140 window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
141 window.setStatusBarColor(0x40000000);
142 window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
143
144 String[] args = getArgsFromIntent(activity.getIntent());
145 FlutterMain.ensureInitializationComplete(activity.getApplicationContext(), args);
146
147 flutterView = viewFactory.createFlutterView(activity);
148 if (flutterView == null) {
149 FlutterNativeView nativeView = viewFactory.createFlutterNativeView();
150 flutterView = new FlutterView(activity, null, nativeView);
151 flutterView.setLayoutParams(matchParent);
152 activity.setContentView(flutterView);
153 launchView = createLaunchView();
154 if (launchView != null) {
155 addLaunchView();
156 }
157 }
158
159 if (loadIntent(activity.getIntent())) {
160 return;
161 }
162
163 String appBundlePath = FlutterMain.findAppBundlePath();
164 if (appBundlePath != null) {
165 runBundle(appBundlePath);
166 }
167 }
GLFWwindow * window
Definition main.cc:45
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlutterView createFlutterView(Context context)

◆ onDestroy()

void io.flutter.app.FlutterActivityDelegate.onDestroy ( )
inline
See also
android.app.Activity::onDestroy()

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 225 of file FlutterActivityDelegate.java.

225 {
226 Application app = (Application) activity.getApplicationContext();
227 if (app instanceof FlutterApplication) {
228 FlutterApplication flutterApp = (FlutterApplication) app;
229 if (activity.equals(flutterApp.getCurrentActivity())) {
230 flutterApp.setCurrentActivity(null);
231 }
232 }
233 if (flutterView != null) {
234 final boolean detach =
235 flutterView.getPluginRegistry().onViewDestroy(flutterView.getFlutterNativeView());
236 if (detach || viewFactory.retainFlutterNativeView()) {
237 // Detach, but do not destroy the FlutterView if a plugin
238 // expressed interest in its FlutterNativeView.
239 flutterView.detach();
240 } else {
241 flutterView.destroy();
242 }
243 }
244 }

◆ onLowMemory()

void io.flutter.app.FlutterActivityDelegate.onLowMemory ( )
inline

Definition at line 275 of file FlutterActivityDelegate.java.

275 {
276 flutterView.onMemoryPressure();
277 }

◆ onNewIntent()

void io.flutter.app.FlutterActivityDelegate.onNewIntent ( Intent  intent)
inline
Parameters
intentThe new intent that was started for the activity.
See also
android.app.Activity::onNewIntent(Intent)

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 170 of file FlutterActivityDelegate.java.

170 {
171 // Only attempt to reload the Flutter Dart code during development. Use
172 // the debuggable flag as an indicator that we are in development mode.
173 if (!isDebuggable() || !loadIntent(intent)) {
174 flutterView.getPluginRegistry().onNewIntent(intent);
175 }
176 }

◆ onPause()

void io.flutter.app.FlutterActivityDelegate.onPause ( )
inline
See also
android.app.Activity::onPause()

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 183 of file FlutterActivityDelegate.java.

183 {
184 Application app = (Application) activity.getApplicationContext();
185 if (app instanceof FlutterApplication) {
186 FlutterApplication flutterApp = (FlutterApplication) app;
187 if (activity.equals(flutterApp.getCurrentActivity())) {
188 flutterApp.setCurrentActivity(null);
189 }
190 }
191 if (flutterView != null) {
192 flutterView.onPause();
193 }
194 }

◆ onPostResume()

void io.flutter.app.FlutterActivityDelegate.onPostResume ( )
inline
See also
android.app.Activity::onPostResume()

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 218 of file FlutterActivityDelegate.java.

218 {
219 if (flutterView != null) {
220 flutterView.onPostResume();
221 }
222 }

◆ onRequestPermissionsResult()

boolean io.flutter.app.FlutterActivityDelegate.onRequestPermissionsResult ( int  requestCode,
String[]  permissions,
int[]  grantResults 
)
inline

Definition at line 125 of file FlutterActivityDelegate.java.

126 {
127 return flutterView
128 .getPluginRegistry()
129 .onRequestPermissionsResult(requestCode, permissions, grantResults);
130 }

◆ onResume()

void io.flutter.app.FlutterActivityDelegate.onResume ( )
inline
See also
android.app.Activity::onResume()

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 204 of file FlutterActivityDelegate.java.

204 {
205 Application app = (Application) activity.getApplicationContext();
206 if (app instanceof FlutterApplication) {
207 FlutterApplication flutterApp = (FlutterApplication) app;
208 flutterApp.setCurrentActivity(activity);
209 }
210 }

◆ onStart()

void io.flutter.app.FlutterActivityDelegate.onStart ( )
inline
See also
android.app.Activity::onStart()

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 197 of file FlutterActivityDelegate.java.

197 {
198 if (flutterView != null) {
199 flutterView.onStart();
200 }
201 }

◆ onStop()

void io.flutter.app.FlutterActivityDelegate.onStop ( )
inline
See also
android.app.Activity::onStop()

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 213 of file FlutterActivityDelegate.java.

213 {
214 flutterView.onStop();
215 }

◆ onTrimMemory()

void io.flutter.app.FlutterActivityDelegate.onTrimMemory ( int  level)
inline

Definition at line 266 of file FlutterActivityDelegate.java.

266 {
267 // Use a trim level delivered while the application is running so the
268 // framework has a chance to react to the notification.
269 if (level == TRIM_MEMORY_RUNNING_LOW) {
270 flutterView.onMemoryPressure();
271 }
272 }

◆ onUserLeaveHint()

void io.flutter.app.FlutterActivityDelegate.onUserLeaveHint ( )
inline
See also
android.app.Activity::onUserLeaveHint()

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 256 of file FlutterActivityDelegate.java.

256 {
257 flutterView.getPluginRegistry().onUserLeaveHint();
258 }

◆ onWindowFocusChanged()

void io.flutter.app.FlutterActivityDelegate.onWindowFocusChanged ( boolean  hasFocus)
inline
Parameters
hasFocusTrue if the current activity window has focus.
See also
android.app.Activity::onWindowFocusChanged(boolean)

Implements io.flutter.app.FlutterActivityEvents.

Definition at line 261 of file FlutterActivityDelegate.java.

261 {
262 flutterView.getPluginRegistry().onWindowFocusChanged(hasFocus);
263 }

◆ registrarFor()

Registrar io.flutter.app.FlutterActivityDelegate.registrarFor ( String  pluginKey)
inline

Definition at line 120 of file FlutterActivityDelegate.java.

120 {
121 return flutterView.getPluginRegistry().registrarFor(pluginKey);
122 }

◆ valuePublishedByPlugin()

public< T > T io.flutter.app.FlutterActivityDelegate.valuePublishedByPlugin ( String  pluginKey)
inlinepackage

Definition at line 115 of file FlutterActivityDelegate.java.

115 {
116 return (T) flutterView.getPluginRegistry().valuePublishedByPlugin(pluginKey);
117 }

The documentation for this class was generated from the following file: