onpause

Unable to pause activity exception in android

吃可爱长大的小学妹 提交于 2019-12-11 23:12:16
问题 Hi I am developing small android application. So my application contains following things. 3 Activities consider A1, A2, A3. A1 is my launcher activity. my application also contains one background service. So when I click on button inside A1 it will start background service. Inside background service I am starting A2. I am also doing some calculations in service so after those calculations i am starting activity A3 from service only. SO my problem is here when I start service from A1 it will

Android onResume not called after finish() command on different activity

牧云@^-^@ 提交于 2019-12-11 11:04:40
问题 I have 2 Activities. My first activity calls the second activity. Once a button is clicked in the second activity it calls the finish() method on that activity causing it to return to Activity 1. This is fine, but my problem is that when it returns none of the expected methods are called (onResume(), onRestart(), on Start()). Is there anything that I could be missing? Anything that can inhibit the call? I have logs in each of the methods making sure that they aren't called. I have also added

Android: surfaceView can't resume activity from pause()

耗尽温柔 提交于 2019-12-11 07:40:13
问题 I am testing surfaceView, basically the app jsut changes the color of the background. The app starts with no issue but when I "pause" the activity and "resume" it, the app is blocked in the "pause()" method loop. this is my code: import java.util.Random; import android.os.Bundle; import android.app.Activity; import android.content.Context; import android.graphics.Canvas; import android.util.Log; import android.view.Menu; import android.view.SurfaceHolder; import android.view.SurfaceView;

Android: Detect when an application as a whole (not individual Activities) is paused/exited?

ⅰ亾dé卋堺 提交于 2019-12-11 05:37:17
问题 One of the Activities in my app starts/binds to a service (also part of my app). I would like that service to continue running as long as the app as a whole is still in the foreground, regardless of which Activity is active. But I need to make sure that the service is stopped when the app as a whole is paused (home button/back button). How can I do that on an application level rather than an Activity level? 回答1: The easiest way is to have a singleton which keeps a track of the state of each

onPause not fired when home button is pressed

给你一囗甜甜゛ 提交于 2019-12-10 18:07:48
问题 I have an Android AppCompatActivity that fails to fire onPause event when the Home button is pressed. According to the Android documentation: The system calls this method as the first indication that the user is leaving your activity (though it does not always mean the activity is being destroyed); However, whenever I am in the AppCompatActivity, onPause does not fire when Home button is pressed. Otherwise it fires as expected for back button or normal close of the AppCompatActivity. I have

How to stop Service when app is paused or destroyed but not when it switches to a new Activity?

情到浓时终转凉″ 提交于 2019-12-10 15:38:40
问题 Currently I have a Service which I am using to play a sound file in the background whilst the app is open: public class BackgroundSoundService extends Service { MediaPlayer player; public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { super.onCreate(); player = MediaPlayer.create(this, R.raw.sound); player.setLooping(true); player.setVolume(100, 100); } public int onStartCommand(Intent intent, int flags, int startId) { player.start(); return 1; } @Override

Can we execute code after startActivity() before it gets paused?

六眼飞鱼酱① 提交于 2019-12-08 03:24:26
问题 My question is... If we try to execute some code after startActivity() will it we fully executed before the onPause() of the current Activity is called? That is, I do not know if startActivity() will actually be called when the method that contains it reaches the end (something that happens with the finish() method). I have an example in which I want to detach() an object (that has a Database connection) after a new Activity is started based on some conditions, but I need this object to

Restarting/Pausing Thread in onResume/onPause

我怕爱的太早我们不能终老 提交于 2019-12-07 01:15:44
问题 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

onPause() Android

ぐ巨炮叔叔 提交于 2019-12-06 12:39:07
问题 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

Gradle - How to add some delay pause hang in Gradle

独自空忆成欢 提交于 2019-12-06 00:09:28
问题 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? 回答1: 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