This question is based on this older one (not by me).
I need to run the following code on my main activity (the one that launches first when I open my app):
public static boolean isInFront;
@Override
protected void onResume() {
//isInFront = true;
}
@Override
protected void onPause() {
//isInFront = false;
}
The problem is, onResume() causes my app to crash when I open it. As I understand it, this is what should happen because onCreate() should be called for the first activity the app runs (I also have that function later in my code).
But I really need this bit of code there to tell me when the main activity is the one currently active/in the foreground.
Is there any way to fix this so that I can keep onResume() in my main activity without running it instead of onCreate() when the app starts? Many thanks!