onpause

Why override Activity.onDestroy() if it isn't reliably called?

前提是你 提交于 2019-12-05 21:30:46
I'm confused why anyone would ever override Activity.onDestroy() instead of onPause() if according to the documentation : There are situations where the system will simply kill the activity's hosting process without calling this method (or any others) in it, I see much code that overrides onDestroy() despite this warning. Why? Why override Activity.onDestroy() if it isn't reliably called? It's not that it isn't reliably called... it's just that it isn't the only way the Activity can be killed. The Android system might trash your entire process without giving the ActivityManager the chance to

Call finish() inside onPause() but not when orientation changes

对着背影说爱祢 提交于 2019-12-05 13:43:43
I have an app that needs to call finish when someone exits its main activity (so i do not want it to be paused ), even by pressing home activity has to be finished, to handle this currently i simply call finish() in my onPause() method, since everything is done with fragments it works pretty well and gives no stability issues. My only problem is that i cannot handle orientation changes since onPause() is called before onConfigurationChanged() (allowing me to disable this behavior when rotation occurs). I could create a service that handles this but its way to complex. Any idea? You can use

Restarting/Pausing Thread in onResume/onPause

断了今生、忘了曾经 提交于 2019-12-05 04:53:07
I'm have a game that's uses SurfaceView implementation to display the objects. I have a thread which draws the SurfaceView time-to-time to the screen. The game is running completely. Unfortunately, it needed to have a pause function whenever the game is interrupted. Well, I know that I need to manipulate onResume and onPause . But I can't get it right. The error points me back to surfaceCreated where I start the thread telling me that the thread has started already. I tried using the resume and suspend on the onResume and onPause respectively but nothing changed. How can I achieve this? I have

OnResume Camera Reinit Black Screen

江枫思渺然 提交于 2019-12-05 04:45:42
I have a problem. After initializing the camera for a preview and bringing another app into focus, then back to my app: the preview shows up black. If I continue to take a picture, it takes a picture of where I point the camera normally. Am I doing something wrong on the OnResume() override? Relative code is below: public void ReleaseCamera() { if (myCamera != null) { myCamera.Release(); myCamera = null; } } protected override void OnPause() { base.OnPause(); if (myButtonState == ButtonState.CameraActive) ReleaseCamera(); } protected override void OnResume() { base.OnResume(); if

Get onPause & onResume like events at application/task level

喜欢而已 提交于 2019-12-05 02:30:13
I was wondering what could be the reason for not having a callback at the application level when an application goes to background and comes to the foreground. Activity class's onPause and onResume are only called on the current top activity. If I want to stop some background task that has the application level scope, then there is no easy way I can stop it when the app goes to background. There is high demand for these event callbacks. Why doesn't Android have a app level callback on pause and resume of applications? Can it be implemented in Android at the task(activity stack) level if not at

MyLocationOverlay disableMyLocation() not seeming to work

坚强是说给别人听的谎言 提交于 2019-12-05 01:00:37
问题 Just wasted 3 hours trying to figure out why the GPS icon is still showing up in the notification bar when my map activity is paused. I've narrowed it down to having to do with the MyLocationOverlay object I'm using (I also have a LocationListener and a GpsStatus.Listener). @Override protected void onPause() { super.onPause(); manager.removeUpdates(locListener); manager.removeGpsStatusListener(statListener); myLocOverlay.disableMyLocation(); //!doesn't seem to work myLocOverlay.disableCompass

onPause() Android

╄→尐↘猪︶ㄣ 提交于 2019-12-04 19:03:01
I have an app that connects to an URL every X seconds in an onPostExecute of a library that I had done. When I close the app or go back with the back button, it must stop with an override of the onPause() method on the main activity class. I want to control this with my own library to facilitate the creation of class for new developers, but if I override it on the library onPause() method, it continues making connections. There's a way to do these on my library? Here my code on the main class: @Override public void onPause() { super.onPause(); myLib.stopResource(); myLib.flagRefresh = false; }

Gradle - How to add some delay pause hang in Gradle

泪湿孤枕 提交于 2019-12-04 06:17:20
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? First, I'd try to find a better solution than waiting for so long every time. Anyway, to delay the first task for 45 seconds, you can do: firstTask.doLast { sleep(45 * 1000) } A good way to familiarize yourself with Groovy's core APIs is to study the Groovy JDK (also known as GDK). It's also a handy reference. If you want to run integration tests in Tomcat, then simply use the Gradle Tomcat Plugin like this:

Pausing threads properly onPause() and onResume() with a SurfaceView and Thread in Android

有些话、适合烂在心里 提交于 2019-12-03 20:57:45
To run the games that I've created on Android, I've been using a GamePanel contains the methods onDraw() and onTouch(). I also have been using a GameThread class that calls onDraw() and update() repeatedly. My activity instantiates the GamePanel and my GamePanel instantiates the GameThread. My onPause() just sets the condition in the while-loop inside the thread, run, to false. My onResume() used to just set that equal to true, however that would give me a force close error ( see edit #1 ) every time I tried to resume the app. So instead to fix the problem I just re-instantiated the thread,

MyLocationOverlay disableMyLocation() not seeming to work

我的未来我决定 提交于 2019-12-03 16:42:40
Just wasted 3 hours trying to figure out why the GPS icon is still showing up in the notification bar when my map activity is paused. I've narrowed it down to having to do with the MyLocationOverlay object I'm using (I also have a LocationListener and a GpsStatus.Listener). @Override protected void onPause() { super.onPause(); manager.removeUpdates(locListener); manager.removeGpsStatusListener(statListener); myLocOverlay.disableMyLocation(); //!doesn't seem to work myLocOverlay.disableCompass(); } If anyone has any idea why this is happening please help so I don't pull all my hair out. I can't