We have Splash extends Activity
which is the starting activity of our application. We also have CustomApplication extends Application
class which is invoked when the app process in invoked.
Now we have the following requirement. Whenever the app/process is launched, call Utils.doSomeDBWork()
function.
For this purpose we have put this function call in onCreate()
of Splash
and CustomApplication
classes. The reason that we have put this call inside CustomApplication
is that our application can be launched via deeplinks/notifications
in which Splash
won't be called. But the problem is that if the app was killed and launched via Splash
, then the same function will be called twice. One from CustomApplication
and the other through Splash
.
So basically my question is that if the function has already been called from CustomApplication
, then don't call this function from Splash
. I can think of doing it by using some static variable or Shared Preferences. But don't think that this is a clean way. Is there any other way to achieve this, like passing some info through Intents
etc?