You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Hi there, I'm experience a bug with AndroidAnnotations 3.3.1.
I have an @efragment support fragment with an @AfterInject method where I want to perform some initialization. Calling a @Background/@WakeLock annotated method from within the @AfterInject method results in a NullPointerException.
java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.PowerManager$WakeLock android.os.PowerManager.newWakeLock(int, java.lang.String)' on a null object reference : ... )
Looking at the generated code I see this:
private void init_(Bundle savedInstanceState) {
OnViewChangedNotifier.registerOnViewChangedListener(this);
Resources resources_ = getActivity().getResources();
...
restoreSavedInstanceState_(savedInstanceState);
init(); <- This is my @AfterInject method
powerManager_ = ((PowerManager) getActivity().getSystemService(Context.POWER_SERVICE));
}
The problem is that the powerManager_ is initialized after calling my @AfterInject method and thus the NullPointerException.
Shouldn't any required System Components/Services be initialized before calling any annotated method?
The fix for this would be to call any annotated methods after having first the reference to the required System Components/Services.
Putting my initialization code in a @AfterViews method doesn't result in the same exception.