1

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?

Miquel
  • 8,339
  • 11
  • 59
  • 82

2 Answers2

4

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Good! Many thanks! I may missed my glasses when looking at the application callbacks... :) – Miquel Jun 30 '14 at 06:15
  • Is there any way to achieve in api 10? I've tried with reflection but registerActivityLifecycleCallbacks() it's not existing in API 10. – Miquel Jun 30 '14 at 08:12
  • Ok, found this thread, possible duplicate: http://stackoverflow.com/questions/15764461/android-activity-in-background and this library: https://github.com/BoD/android-activitylifecyclecallbacks-compat – Miquel Jun 30 '14 at 08:16
  • This can work if you have access to Activity... So the question is how to do it if there is no access to the Activity? (Intel XDK app) – Miquel Jun 30 '14 at 08:25
  • @Miguel: Sorry, I know of no way to address your problem prior to API Level 14 except by modifying the activity. – CommonsWare Jun 30 '14 at 10:53
1

Mouse right click Source --> Override/Implement Method you can find methods which you need it. But make sure add your library on your project

drojokef
  • 425
  • 1
  • 5
  • 15