I have customized Application
class in my app to initialize some global objects.
But I noticed that this Application
class runs not only in normal app start, but in other occasions like unit testing. This is not desirable, because those initializations in Application
class may have side effects on the test results.
So is there any way in Application
class to find out if the application is running for a normal usage by user, or for other purposes?
I want to achieve something like this:
public class MyApplication extends Application
{
@Override
public void onCreate()
{
super.onCreate();
if (isNormalRun()) //<-- How to implement this?
initGlobalObjects();
}
private void initGlobalObjects()
{
SomeClass.initializeInstance(this);
OtherClass.initializeInstance(this);
//...
}
}