First time poster long time reader, I've really learned a lot reading
this group ...
Ok I'm working on a splash screen that pauses for 1.5 seconds and
works great, except for one thing.
Once the timer is started in onCreate if the configuration
(orientation) changes then the timer gets reset and then end result is
it starts my ParchmentActivity.java twice. How can I prevent the
handler from sending the intent twice?
Thanks in advance!
here is my code:
public class SplashScreen extends Activity {
private static final int SPLASH_DISPLAY_TIME = 1500; /* 1.5
seconds */
private static final String TAG = "Parchment";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Create a new handler with which to start the main activity
and close this splash activity after SPLASH_DISPLAY_TIME
has
elapsed. */
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent parchment = new Intent(SplashScreen.this,
ParchmentActivity.class);
SplashScreen.this.startActivity(parchment);
SplashScreen.this.finish();
overridePendingTransition(R.anim.fade_main_in,
R.anim.fade_splash_out);
}
}, SPLASH_DISPLAY_TIME);
}
/* I found a suggestion to try overriding onConfigurationChanged()
but it doesn't stop a new timer from being started */
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
/* I also tried overriding onStart() but this also doesn't stop a
new timer. What exactly is called when an orientation configuration
changes happens? */
@Override
public void onStart() {
super.onStart();
setContentView(R.layout.splash);
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en