-1

Suppose if I am using my android app and I click on home button in say xyz activity. Now at this point the app is running in background, now if the app is launched again the xyz activity will be brought to front that is fine but I want to check if the app is called from background or now. I have some confusion if it has to do something with onResume() method but dont know the exact solution. Anyone please help me with this topic.

Syn3sthete
  • 4,151
  • 3
  • 23
  • 41
  • You stated earlier that you don't want to use a taskmanager to check if the app is already running in the background. So please post the code that tries to make sure that the activity first runs in the background and is called to the front next time you start it. Only that way we can try to tell you something about the expected behaviour. – MarchingHome Oct 17 '12 at 06:39
  • Why a downvote for this question? Could somebody explain me – Syn3sthete Mar 07 '13 at 06:44

2 Answers2

0

Please, read this article. If you create activity you will pass through onCreate -> onStart -> onResume, and if you returns to activity you will pass onRestart -> onStart -> onResume.

Jin35
  • 8,602
  • 3
  • 32
  • 52
0

If you want to know if your application use onResume(), you can implement something like that in your activity and check the logs while you go back to the Home.

@Override
public void onResume() {
   super.onResume();
   Log.d(“Test”, “onResume”);
}

In your log you should see something like that if you also implement onPause, onStop and onStart and then press the home button :

12-09 04:18:47.696: D/Test(2995): onPause
12-09 04:18:50.346: D/Test(2995): onStop

And when you launch the app again :

12-09 04:20:08.726: D/Test(2995): onStart
12-09 04:20:08.766: D/Test(2995): onResume
g0ldsteinsbr0
  • 249
  • 2
  • 20