java - Android Splash Screen only opens if I install the app -
i teen programmer looking help.
i wrote simple splash screen thingy , works if uninstall , reinstall app.
please have , see if doing wrong.
thanks!
package ca._____.test; import android.app.activity; import android.content.intent; import android.os.bundle; import android.util.log; import android.view.window; import android.view.windowmanager; public class splash extends activity { private static string tag = splash.class.getname(); private static long sleep_time = 5; // sleep time @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.requestwindowfeature(window.feature_no_title); // removes title bar this.getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); // removes notification bar setcontentview(r.layout.spash_screen); // start timer , launch main activity intentlauncher launcher = new intentlauncher(); launcher.start(); } private class intentlauncher extends thread { @override /** * sleep time , start new activity. */ public void run() { try { // sleeping thread.sleep(sleep_time*1000); } catch (exception e) { log.e(tag, e.getmessage()); } // start main activity intent intent = new intent(splash.this, mainactivity.class); splash.this.startactivity(intent); splash.this.finish(); } } }
try start intentlauncher thread in onresume(), time activity's onresume() called activity created , show screen.
second , best thing start mainactivity in onresume() in handler this
new handler().postdelayed(new runnable() { public void run() { intent intent = new intent(splash.this, mainactivity.class); splash.this.startactivity(intent); splash.this.finish(); } }, 5000);
this best way.
Comments
Post a Comment