Questions tagged [onresume]

onResume is an Activity life-cycle event generated by the Android OS when an Activity becomes the top-most one in the stack.

onResume is an Activity life-cycle event generated by the Android OS when an Activity becomes the top-most one in the stack.

More can be read about this at the Android Developer Site.

712 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
229
votes
20 answers

Fragment onResume() & onPause() is not called on backstack

I have multiple fragment inside an activity. On a button click I am starting a new fragment, adding it to backstack. I naturally expected the onPause() method of current Fragment and onResume() of new Fragment to be called. Well it is not…
Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167
95
votes
9 answers

How to use onResume()?

Can anyone give me an example that uses onResume() in Android? Also, if I want to restart the activity at the end of the execution of another, which method is executed—onCreate() or onResume()? And if I want to update data, how do I put it in…
Zizou
  • 1,891
  • 3
  • 15
  • 16
56
votes
10 answers

ViewPager with fragments - onPause(), onResume()?

When using ViewPager with fragments, our onPause, onResume methods are not called when moving between tabs. Is there any way we can figure out in the fragment when we're being made visible or being hidden? Unfortunately I have logic in onResume,…
user291701
  • 38,411
  • 72
  • 187
  • 285
51
votes
4 answers

Android onResume() method equivalent in Flutter

I am working on a Flutter app and need to pop the screen. I tried initState() method but no luck. initState() gets called when I open a class for the first time. Do we have an equivalent of Android onResume() method in Flutter? Any ideas?
Satish Saini
  • 2,880
  • 3
  • 24
  • 38
51
votes
8 answers

Android - save/restore fragment state

I have an Activity in which I go through several fragments. In every fragment I have several views (EditText, ListView, Map, etc). How can I save the instance of the fragment that is shown at that moment? I need it to work when the activity is…
Stanete
  • 691
  • 1
  • 7
  • 13
47
votes
18 answers

Android ViewPager setCurrentItem not working after onResume

I've got this strange issue, ViewPager's setCurrentItem(position, false) works perfectly fine, then im switching to another activity, and after I'm back to the first activity, the ViewPager always ends up on the first item. Even though I've added…
Maciej Boguta
  • 1,354
  • 1
  • 12
  • 15
40
votes
3 answers

Android - Performing stop of activity that is not resumed

When I push my app to background, and do some other stuff like whatsapp or sms, onResume it works great. But I recently discovered that when I open/launch facebook app while my app is on background, I don't know what happens... But onResume, the…
Salmaan
  • 3,543
  • 8
  • 33
  • 59
37
votes
2 answers

Which activity method is called when orientation changes occur?

Which method of the lifecycle is called when orientation changes occur? My application executes the onResume() method or maybe reloads the whole activity because I've set one boolean to check whether it is first run or not. I've read…
Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
31
votes
6 answers

Alternative for the onResume() during Fragment switching

onResume() method won't get called when we switch between fragments more than one time. So, is there any better way to handle resume operation?
Manjunath
  • 2,063
  • 2
  • 29
  • 60
27
votes
3 answers

onDestroy gets called each time the screen goes on

My application gets killed each time that it comes back from the screen-off-state. I fetch all the information that my app does, but I can't find out why it calls onDestroy. It's the first time I'm seeing this behavior in my applications. My main…
mikepenz
  • 12,708
  • 14
  • 77
  • 117
22
votes
4 answers

How to pause, and resume a TimerTask/ Timer

I have an animation in my Android app that flashes a TextView different colors. I've used a TimerTask, Timer, and Runnable method to implement this. What I need to do is stop the thread when a user leaves the app during this animation in onPause(),…
embersofadyingfire
  • 523
  • 1
  • 4
  • 16
16
votes
7 answers

How can I know that OnResume comes after onCreate?

I have few activities and from one activity I open another and that go back to the first one... The point is onCreate is called ones , and onResume every time when the activity is show. For example when I close B that was previouslly started from A,…
Lukap
  • 31,523
  • 64
  • 157
  • 244
16
votes
3 answers

Android: "Application level" Pause and Resume

I've been trying to get Application Level Pause and Resume similar to an activity's onPause and onResume. I know there's no API that has this functionality. I try to follow this post:…
TMacGyver
  • 1,281
  • 3
  • 12
  • 27
15
votes
4 answers

Android onCreate onResume

I have a problem. When I start for the first time my android application, in the main activity both the onCreate and the onResume are called. but I want to be called only the onCreate. What can I do?
Alessio
  • 183
  • 1
  • 1
  • 4
1
2 3
47 48