发生在哪个时间点:onCreate 还是 configureFlutterEngine?

huangapple go评论77阅读模式
英文:

What happens first: onCreate or configureFlutterEngine?

问题

onCreateconfigureFlutterEngine 中哪一个会首先发生,我需要明确这一点:

我在这里:

public class MainActivity extends FlutterActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
    }
}

我必须确切地知道哪一个会首先被调用,而不仅仅是打印出来看。

英文:

I need to know which one of these happens first:

onCreate or configureFlutterEngine?

I'm in

public class MainActivity extends FlutterActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
    }
}

and I need to be certain of which one is called first. I must know it for sure, not simply print and see.

答案1

得分: 1

  • 在 onCreate 方法之前

  • 关于 configureFlutterEngine 的详细信息,请参阅

https://api.flutter.dev/javadoc/io/flutter/embedding/android/FlutterActivity.html

> public void configureFlutterEngine(@NonNull FlutterEngine
> flutterEngine)
>
> 用于子类轻松配置 FlutterEngine 的钩子,例如注册插件。
>
> 此方法在 provideFlutterEngine(Context) 之后调用。

英文:
  • onCreate first

  • about configureFlutterEngine see

https://api.flutter.dev/javadoc/io/flutter/embedding/android/FlutterActivity.html

> public void configureFlutterEngine(@NonNull FlutterEngine
> flutterEngine)
>
> Hook for subclasses to easily configure a FlutterEngine, e.g., register > plugins.
>
> This method is called after provideFlutterEngine(Context).

huangapple
  • 本文由 发表于 2020年4月7日 10:58:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/61072118.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定