tags:

views:

73

answers:

2

Hi,

I need some help in application exit handling. My application has multiple Activity say : - EntryAct, Act1, Act2 .... Act10.

When user presses home key on any of these Activities, I need to do some flag setting.

Handling home key in every application Activity is not possible! Can someone tell how this can be achieved?

Can't change anything in OnPause,OnStop or OnDestory of all activities Act1... Act10. :-(

A: 

Do it in the onPause() method which is called as soon as the activity is no more in the foreground.

WarrenFaith
+1  A: 

Hello Mitesh Patel, your issue can be solved if you use a custom Application class. say like

public class MyApp extends android.app.Application { }

and inside this put your code that you want to be called anywhere in your app.

Now only you require to get the application object in your activity like this

MyApp app = (MyApp) getApplication(); app.setUpBeforeClosingApp();

and you can put this inside every onDestroy of Activity and from here code handling before closing actions can be achieved.

y ramesh rao