Open Double-Dude opened 6 years ago
Yep. The library internally relies on the onStart()
callback so I suggest starting the app state monitor in onCreate()
of either your Application
or Activity
class.
Is there any particular reason you only want to kick it off in onResume()
?
Hi @jenzz , I put the appStateMonitor.start() in a xxxClient class. The client is started in Fragment's onCreate/onCreateView method. So I found out the Fragment's onCreate will only get called after Activity's onStart() if you use transcation.commit().
So the appStateMonitor.start() will be called after onStart() of Activity class and it doesn't work well at the first entering background.
So I found out the Fragment's onCreate will only get called after Activity's onStart() if you use transcation.commit().
This obviously depends on when you are performing the Fragment
transaction in your Activity
.
I'm happy to have a look at it, if you can provide some sample code.
It's working fine when I have the following code before onStart() method gets code, i.e. in onCreate method. But if I have the following code added after onStart() in Activity, then app enters background onAppDidEnterForeground will not get fired at the first time. If I come back to foreground and re-enter background, then it works as expected.