Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FlutterPlayStoreSplitApplication.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.android;
6
7import androidx.annotation.CallSuper;
8import com.google.android.play.core.splitcompat.SplitCompatApplication;
9import io.flutter.FlutterInjector;
10import io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager;
11
12// TODO(garyq): Add a note about deferred components automatically adding this to manifest via
13// manifest variable injection once it is implemented.
14/**
15 * Flutter's extension of {@link SplitCompatApplication} that injects a {@link
16 * PlayStoreDeferredComponentManager} with {@link FlutterInjector} to enable Split AOT Flutter apps.
17 *
18 * <p>To use this class, either have your custom application class extend
19 * FlutterPlayStoreSplitApplication or use it directly in the app's AndroidManifest.xml by adding
20 * the following line:
21 *
22 * <pre>{@code
23 * <manifest
24 * ...
25 * <application
26 * android:name="io.flutter.embedding.android.FlutterPlayStoreSplitApplication"
27 * ...>
28 * </application>
29 * </manifest>
30 * }</pre>
31 *
32 * This class is meant to be used with the Google Play store. Custom non-play store applications do
33 * not need to extend {@link com.google.android.play.core.splitcompat.SplitCompatApplication} and
34 * should inject a custom {@link
35 * io.flutter.embedding.engine.deferredcomponents.DeferredComponentManager} implementation like so:
36 *
37 * <pre>{@code
38 * FlutterInjector.setInstance(
39 * new FlutterInjector.Builder().setDeferredComponentManager(yourCustomManager).build());
40 * }</pre>
41 */
42public class FlutterPlayStoreSplitApplication extends SplitCompatApplication {
43 @Override
44 @CallSuper
45 public void onCreate() {
46 super.onCreate();
47 // Create and inject a PlayStoreDeferredComponentManager, which is the default manager for
48 // interacting with the Google Play Store.
49 PlayStoreDeferredComponentManager deferredComponentManager =
50 new PlayStoreDeferredComponentManager(this, null);
53 .setDeferredComponentManager(deferredComponentManager)
54 .build());
55 }
56}
Builder setDeferredComponentManager( @Nullable DeferredComponentManager deferredComponentManager)
static void setInstance(@NonNull FlutterInjector injector)