I got a weird problem with one of my Android app. I will explain myself :
I have a SplashScreen (sort of) which is an activity. Basically, it stays 1 second and after this time a handler is called. This handler launches my
HomeActivity
, which extendsRoboActivity
(Roboguice API).During this launch, I see in my stack trace that Roboguice is initializing, and my class too. So it takes 1-2 seconds more to launch the
HomeActivity
(after the 1 second wait of the SplashScreen).So basically, this is here that I got a problem. During this 1-2 seconds of loading, the SplashScreen is the one showing in front, and the
HomeActivity
only appears after this 2 seconds. If the user clicks, during these seconds, on the screen, it will be theHomeActivity
that will trigger the event. It means that if you click on the SplashScreen, and you wait, when theHomeActivity
will show, you will hear a click sound and the button, located where the user clicked, will trigger.
I find it very disturbing for the user. So, at the moment, I tried to :
Deactivate the buttons in the xml layout by adding
android:enabled="false" android:clickable="false"
Reactivate the buttons by adding in the onResume function :
button.setEnabled(true); button.setClickable(true);
I see in the stacktrace that the
OnClickListener
is triggered just after theonResume
. So at this moment, the buttons are re-enabled and so it clicks. I tried with postOnResume too, it doesn't work either.
Did you experienced the same behavior that I have now ? Any idea how to fix it ?