react lifecycle methods understanding

1) componentWillReceiveProps is called before componentWillUpdate in React’s update lifecycle. You are right that componentWillReceiveProps allows you to call setState. On the other hand componentWillUpdate is a callback to use when you need to respond to a state change. The fundamental difference between props and state is that state is private to the component. That’s … Read more

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

Detect if the application in background or foreground in swift

[UIApplication sharedApplication].applicationState will return current state of applications such as: UIApplicationStateActive UIApplicationStateInactive UIApplicationStateBackground or if you want to access via notification see UIApplicationDidBecomeActiveNotification Swift 3+ let state = UIApplication.shared.applicationState if state == .background || state == .inactive { // background } else if state == .active { // foreground } switch UIApplication.shared.applicationState { case .background, … Read more

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

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

Android app out of memory issues – tried everything and still at a loss

I still don’t understand why inactive activities that are on the stack don’t get reaped, and I’d really love to figure that out. This is not how things work. The only memory management that impacts activity lifecycle is the global memory across all processes, as Android decides that it is running low on memory and … Read more

Fragment lifecycle – which method is called upon show / hide?

Similar to activity lifecycle, Android calls onStart() when fragment becomes visible. onStop() is normally called when fragment becomes invisible, but it can also be called later in time. Depending on your layout Android can call onStart() even, when your Fragment is not yet visible, but it belongs to a visible parent container. For instance, this … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)