Android Fragment onCreateView vs. onActivityCreated

If your view is static, then moving any code to the onActivityCreated method is not necessary. But when you – for instance, fill some lists from the adapter, then you should do it in the onActivityCreated method as well as restoring the view state when setRetainInstance used to do so. Also accessing the view hierarchy … Read more

Automatically log Android lifecycle events using ActivityLifecycleCallbacks?

I don’t have any firsthand experience but judging from the API you can just write your own class that implements the Application.ActivityLifecycleCallbacks interface and register that class on the provided Application class instance getApplicaton().registerActivityLifecycleCallbacks(yourCustomClass); This class will receive the same callbacks as your individual activities. Good luck. PS. This is API level 14 btw, so … Read more

onNewIntent() lifecycle and registered listeners

onNewIntent() is meant as entry point for singleTop activities which already run somewhere else in the stack and therefore can’t call onCreate(). From activities lifecycle point of view it’s therefore needed to call onPause() before onNewIntent(). I suggest you to rewrite your activity to not use these listeners inside of onNewIntent(). For example most of … Read more

Android: Under what circumstances would a Dialog appearing cause onPause() to be called?

onPause() is called when your activity is no longer at the top of the activity stack. A Dialog by itself is not an Activity, so will not replace the current Activity at the top of the stack, so will not cause anything to pause. A dialog (lower-case) does not need to be implemented by a … Read more

How can i remove a singleton spring bean from ApplicationContext?

Removing definition does both : removing definition and destroying (removing all container references on that bean) corresponding Singleton : ((BeanDefinitionRegistry) beanFactory).removeBeanDefinition(“myBean”); If you just need to remove the singleton then : ((DefaultListableBeanFactory) beanFactory).destroySingleton(“myBean”); The latter way may be especially useful if you just registered singleton but haven’t defined any bean definitions, i.e. ((SingletonBeanRegistry) beanFactory).registerSingleton(“myBean”, myBeanInstance);

Is there any lifecycle hook like window.onbeforeunload in Angular2?

<div (window:beforeunload)=”doSomething()”></div> or @Component({ selector: ‘xxx’, host: {‘window:beforeunload’:’doSomething’} .. )} or @Component({ selector: ‘xxx’, .. )} class MyComponent { @HostListener(‘window:beforeunload’) doSomething() { } } This is how to listen to global events. I don’t know if the special behavior of this event is supported where the return value is used as text for the conformation … Read more

What’s the view build time?

The view build time is not a phase. The view build time is that moment when the physical UIViewRoot instance and all of its children is built based on the view declaration, which is usally defined in XHTML or JSP files. The view build time moment is not restricted to a specific JSF lifecycle phase. … Read more