I have a splash screen which handles automatic login. If the user is logged in, it sends s/he directly to the main activity, through the following code:
Intent intent = new Intent(activity, MainActivity.class);
activity.startActivity(intent);
activity.finish();
Where activity is the activity to be finished (I'm not using this
because this method is common to automatic logins, manual logins, social logins etc.)
However about 70% of the time, the splash screen is still there after finishing the main activity. This does not occur during debugging. It looks like it happens when the login happens quickly, which is why it probably never happens during debugging (because everything becomes slow).
Logging has helped my see that, when the problem happens finish()
is indeed being called, but onDestroy()
is not.
I have tried FLAG_ACTIVITY_CLEAR_TOP
, but it doesn't help. noHistory
does work, but brings an unwanted finishing animation and, really, I want to know what the problem with this code is. I've always used it and don't see why it fails.
Thanks in advance.