Questions tagged [onpause]

onPause is an Activity life-cycle event generated by the Android OS when an Activity is no longer the top-most one in the stack.

onPause is an Activity life-cycle event generated by the Android OS when an Activity is no longer the top-most one in the stack.

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

462 questions
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
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
37
votes
9 answers

Android: How to pause and resume a Count Down Timer?

I have developed a Count Down Timer and I am not sure how to pause and resume the timer as the textview for the timer is being clicked. Click to start then click again to pause and to resume, click again the timer's text view. This is my code: …
Mineko
  • 641
  • 2
  • 14
  • 21
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
22
votes
6 answers

onPause() and onStop() in Activity

I am new to Android development and I am still not able to understand the onPause() and onStop() methods in an activity. In my app, I have a static class that I name Counter, and it keeps the state of variables in memory for the app. My app runs…
Stephan Doliov
  • 657
  • 1
  • 6
  • 7
18
votes
4 answers

Flutter: Lifecycle of a Widget and Navigation

I have written a flutter plugin, that displays a camera preview and scans for barcodes. I have a Widget called ScanPage that displays the CameraPreview and navigates to a new Route when a barcode is detected. Problem: When I push a new Route…
hendra
  • 2,531
  • 5
  • 22
  • 34
16
votes
3 answers

Broadcastreceiver and Paused activity

I have a broadcast receiver registered programatically in a activity. It responds to the PACKAGE_REMOVED intent, that fires when a package gets removed. The problem is, it doesn't get this message. I think this is due to that the intent is fired…
Peterdk
  • 15,625
  • 20
  • 101
  • 140
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
3 answers

"persistent state" vs. "current state"

Attempting to decide (for my application) what to save in onPause() and what to save in onSaveInstanceState(), I combed the entire SO for hints and clear guidelines. If I understand correctly, onSaveInstanceState() is best for saving "runtime…
15
votes
1 answer

Android: Save an instance state when app is closed

Possible Duplicate: How do I save an Android application's state? I am new to Java and Android and building some small projects to learn. I made a money tracking app which allows the user to input values and it simply continues to subtract it.…
user1218728
  • 159
  • 1
  • 4
14
votes
0 answers

Why am I getting "Unable to pause activity IllegalStateException: Restarter must be created only during owner's initialization stage" in Android?

I am using a FragmentActivity and sometimes on Crashlytics, I am able to see an exception Fatal Exception: java.lang.RuntimeException: Unable to pause activity Below is the onPause of my FragmentActivity @Override protected void onPause() { …
12
votes
1 answer

Determine Reason for Android Pause

My application is randomly pausing (going into the onPause method) then resuming (going into the onResume method) when I'm not even touching the screen. In logcat, there is no indication what is causing the pause and resume. This only happens on a…
Amandeep Grewal
  • 1,801
  • 3
  • 19
  • 30
12
votes
1 answer

Canvas draw functions not working after screen locked and unlocked

I'm working on an augmented reality application in which I have a camera preview screen on which I draw some markers which moves with respect to device movement. When I lock and unlock the device, the markers freezes and doesn't move further. I'm…
Jas
  • 3,207
  • 2
  • 15
  • 45
12
votes
2 answers

Gradle - How to add some delay pause hang in Gradle

Im looking for a way to insert a pause of few seconds between the calls of two gradle tasks. I can use firstTask.doLast { ..... } something like which can do Linux/Unix sleep 45 Any ideas?
AKS
  • 16,482
  • 43
  • 166
  • 258
1
2 3
30 31