Search code examples
androidonresumeonpauseondestroy

get onResume/onPause/onDestroy from non activity


There is a class in a library that is called from javascript (html5 app). It can't be an Activity extender. The class has access to Activity and WebView objects.

Is it possible to get onResume, onPause and onDestroy activity events from this library class?


Solution

  • On API Level 14+, you can call registerActivityLifecycleCallbacks() on your Application instance to find out about all callbacks to all activities in your app.

    Or, modify your Activity to call the class in the library on each of those callbacks.