0

I just wanna ask Are there any global listener that listens following in Andoird.

  1. The app is shut down. i.e the home or back key pressed. like what we have in iPhone SDK -(void)applicationWillTerminate:(UIApplication *)application

  2. When the app is crash due to uncaught exception.

  3. If the app went to background. The goToBackground or returnToForeGround listener. Just like what we have in iPhone SDK. -(void)applicationDidEnterBackground:(UIApplication *)application -(void)applicationWillEnterForeground:(UIApplication *)application Thanks
Arsalan
  • 149
  • 1
  • 1
  • 5

1 Answers1

1

Points 1 and 3 are addressed by overriding onPause() method of an activity. This is automatically called by the framework when an application goes to background. You might be interested by this short introduction to activity lifecycle in android.

for point 2, you should take a look at the Thread.UncaughtExceptionHandler see this other question for use cases.

Community
  • 1
  • 1
Laurent'
  • 2,611
  • 1
  • 14
  • 22