This is a good resource for LibGDX programming on Android.
As a brief “note to self,” when you need to get access to Flutter widget events that you normally can’t access, override the widget to access lifecycle-related events like
dispose() so you can access them. For example, this image (that comes from this URL) shows how to gain access to those lifecycle methods for a Flutter Drawer. You can do this with any component/widget — and you can also make the code more generic by passing in child widgets — and you can also mix in
WidgetsBindingObserver and then use
didChangeAppLifecycleState to gain access to more events.
Android FAQ: When is the Android Fragment
onCreateOptionsMenu method called?
I was just working through a problem with an Android Menu and MenuItem, and added some debug code to the methods in my Android Fragment, and found that the
onCreateOptionsMenu method is called after
onStart. I didn’t put Log/debug code in every activity lifecycle method, but for the ones I did add logging code to, the specific order of the fragment method calls looked like this:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 13.4, “Understanding the methods in the Scala/Akka Actor lifecycle.”
You’re creating more complicated actors, and need to understand when the methods on an
Actor are called.
In addition to its constructor, an
Actor has the following life-cycle methods:
The order of Android Fragment lifecycle methods: onCreate, onCreateView, onResume, and onCreateOptionsMenu
As a quick “note to self” about the Android Fragment lifecycle, including when the
onCreateOptionsMenu method is executed, I have this debug output from an "Images GridView" in my current application.
The first time I go to the Images GridView:
With all apologies to Google for copying and pasting this block of source code, in my opinion, this simple example is so good at explaining the Android Activity lifecycle so well that it needs to stand out on its own page: