1. Flutterページ埋め込みネイティブ
パブリッククラスMyFlutterActivityはFragmentActivity { FlutterFragment flutterFragment;を拡張します。 @Override protected void onCreate(@Nullable Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_flutter); initFlutterEngine(); attachFlutterFragment(); } 文字列ENGINE_ID = "a"; プライベートFlutterEngine initFlutterEngine(){ FlutterEngine flutterEngine = FlutterEngineCache.getInstance()。get(ENGINE_ID); if(null == flutterEngine){ flutterEngine = new FlutterEngine(this); if flutterEngine.getNavigationChannel()。setInitialRoute( "/"); flutterEngine.getDartExecutor()。executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault()); FlutterEngineCache .getInstance(). put(ENGINE_ID、flutterEngine); messageChannelFunction(this、flutterEngine); } flutterEngineを返します。 } private void attachFlutterFragment(){ if(null == flutterFragment){ flutterFragment = FlutterFragment.withCachedEngine(ENGINE_ID) .shouldAttachEngineToActivity(true) .build(); } getSupportFragmentManager(). beginTransaction(). add(R.id.container、flutterFragment) .commit(); } }