Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Thank you for reporting this issue. We’ve shared this with our product and engineering teams and will continue to provide updates as more information becomes available.
ap...@google.com <ap...@google.com> #4
God bless you, unknown Google developer.
il...@google.com <il...@google.com> #6
The new ContextAware
API will be available in Activity 1.2.0-alpha08 and is used by Fragment 1.3.0-alpha08 and AppCompat 1.3.0-alpha02 to implement FragmentManager's and AppCompatDelegate's pre-onCreate() logic.
e....@gmail.com <e....@gmail.com> #7
Wait, this can't work as advertised.
FragmentActivity extends ComponentActivity
public FragmentActivity(@LayoutRes int contentLayoutId) {
super(contentLayoutId);
init();
}
private void init() {
addOnContextAvailableListener(new OnContextAvailableListener() {
// ...
}
}
ComponentActivity
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
// ...
mContextAwareHelper.dispatchOnContextAvailable(this);
super.onCreate(savedInstanceState);
//...
}
- Call
FragmentActivity
constructor, - which calls
ComponentActivity
super constructor, - which dispatches context available... to noone,
- and calls platform Activity.onCreate.
- Bubble up to
FragmentActivity
constructor and register context listener, - which is invoked synchronously but only after platform
Activity.onCreate
has already been called.
Did I miss something? I'm confused.
e....@gmail.com <e....@gmail.com> #8
Never mind, constructor vs onCreate. :facepalm: Sorry.
il...@google.com <il...@google.com> #9
Re #8 - the fact that these are different things is indeed exactly why this API exists :)
Description
Component used: Activity Version used: 1.2.0-alpha06
The APIs of
LifecycleOwner
provide us with a callback for when you reach theCREATED
state, but for activities that is often after some critical code needs to run.For example:
setTheme
to reset your theme from a branded launch themesetLocalNightMode()
These all need to be called before
super.onCreate()
and specifically the inflation of any layout.It would be nice if there was a composable way to get a callback at that exact time without needing to manually add code to
onCreate()
(which, will fine for app code, is hard to do as a library).