Questions tagged [lifecycle]

A sequence of events or system calls relevant to the creation, startup, inactivation, resuming, shutdown and destruction (cleanup) of some program or its component (activity, library, servlet). Lifecycles are supported by various programming platforms.

2000 questions
450
votes
9 answers

Android activity life cycle - what are all these methods for?

What is the life cycle of an Android activity? Why are so many similar sounding methods (onCreate(), onStart(), onResume()) called during initialization, and so many others (onPause(), onStop(), onDestroy()) called at the end? When are these methods…
Nav
  • 10,304
  • 20
  • 56
  • 83
327
votes
11 answers

Looking to understand the iOS UIViewController lifecycle

Could you explain me the correct manner to manage the UIViewController lifecycle? In particular, I would like to know how to use Initialize, ViewDidLoad, ViewWillAppear, ViewDidAppear, ViewWillDisappear, ViewDidDisappear, ViewDidUnload and Dispose…
Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
213
votes
16 answers

How to retrieve the dimensions of a view?

I have a view made up of TableLayout, TableRow and TextView. I want it to look like a grid. I need to get the height and width of this grid. The methods getHeight() and getWidth() always return 0. This happens when I format the grid dynamically…
greenset
163
votes
2 answers

onNewIntent() lifecycle and registered listeners

I'm using a singleTop Activity to receive intents from a search-dialog via onNewIntent(). What I noticed is that onPause() is called before onNewIntent(), and then afterwards it calls onResume(). Visually: search dialog initiated search intent…
DJayC
  • 1,765
  • 3
  • 12
  • 10
163
votes
4 answers

How to use lifecycle method getDerivedStateFromProps as opposed to componentWillReceiveProps

It looks like componentWillReceiveProps is going to be completely phased out in coming releases, in favor of a new lifecycle method getDerivedStateFromProps:static getDerivedStateFromProps(). Upon inspection, it looks like you are now unable to make…
Andrew
  • 7,201
  • 5
  • 25
  • 34
142
votes
1 answer

What determines the lifecycle of a component (object graph) in Dagger 2?

I'm trying to wrap my head around scopes in Dagger 2, specifically the lifecycle of scoped graphs. How do you create a component that will be cleaned up when you leave the scope. In the case of an Android application, using Dagger 1.x you generally…
Enrico
  • 10,377
  • 8
  • 44
  • 55
136
votes
11 answers

How to check if an activity is the last one in the activity stack for an application?

I want to know if user would return to the home screen if he exit the current activity.
virsir
  • 15,159
  • 25
  • 75
  • 109
111
votes
11 answers

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

I am using the following method to switch between Fragments (in my NavigationDrawer) by showing / hiding them. protected void showFragment(int container, Fragment fragment, String tag, String lastTag, boolean addToBackStack ) { …
Philipp Jahoda
  • 50,880
  • 24
  • 180
  • 187
92
votes
10 answers

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

I spent 4 full days trying everything I can to figure out the memory leak in an app I'm developing, but things stopped making sense a long time ago. The app I'm developing is of social nature, so think profile Activities (P) and list Activities with…
Artem Russakovskii
  • 21,516
  • 18
  • 92
  • 115
84
votes
4 answers

What is the Life Cycle of an iPhone application?

Can anyone explain what is the life cycle process of iPhone? i.e from the start to end of the application life cycle.
Santusura8
  • 869
  • 1
  • 7
  • 5
81
votes
7 answers

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

A snippet from the Android Activities document(scroll down to the "foreground lifetime" line) says : An activity can frequently transition in and out of the foreground—for example, onPause() is called when the device goes to sleep or when a …
curioustechizen
  • 10,572
  • 10
  • 61
  • 110
80
votes
6 answers

Detect if the application in background or foreground in swift

is there any way to know the state of my application if it is in background mode or in foreground . Thanks
Mohammed Aboelwafa
  • 1,035
  • 1
  • 9
  • 13
77
votes
2 answers

Is there any graphical representation of Android views lifecycle (a state diagram)?

We all know about the Android Activity's life cycle and Fragment's life cycles. But is there anything equivalent for views ? This could help, for instance, building custom views or give an in-depth look at a very common and often hidden graphic…
Snicolas
  • 37,840
  • 15
  • 114
  • 173
75
votes
2 answers

Android Fragment onCreateView vs. onActivityCreated

I know that a fragment's view hierarchy has to be inflated in onCreateView, but what other functionality can be in onCreateView vs. what should wait for onActivityCreated? My current implementation uses separate activities for everything, and a…
68
votes
2 answers

Do docker containers retain file changes?

This is a very basic question, but I'm struggling a bit and would like to make sure I understand properly. After a container is started from an image and some changes done to files within (i.e.: some data stored in the DB of a WebApp running on the…
Julian Cerruti
  • 1,918
  • 2
  • 16
  • 16
1
2 3
99 100