i trying find way skip flash screen clicking on screen of activity. came , works. problem after click , new activity called, boolean false default if runs again , intent called twice. doing wrong?
relativelayout onclickskipscreen = (relativelayout)findviewbyid(r.id.splashscreenview); onclickskipscreen.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { onclickskip = true; /*loading.interrupt(); intent splashscreen = new intent(splashscreen.this, homescreen.class); startactivity(splashscreen); overridependingtransition(r.anim.fade_in, r.anim.fade_out); finish();*/ } }); thread loading = new thread() { @override public void run() { if (!onclickskip) { try { sleep(2573); intent splashscreen = new intent(splashscreen.this, homescreen.class); startactivity(splashscreen); overridependingtransition(r.anim.fade_in, r.anim.fade_out); } catch (exception e) { e.printstacktrace(); } { finish(); } } else if (onclickskip) { try { intent splashscreen = new intent(splashscreen.this, homescreen.class); startactivity(splashscreen); overridependingtransition(r.anim.fade_in, r.anim.fade_out); } catch (exception e) { e.printstacktrace(); } { finish(); } } } }; loading.start(); }
use sharedpreference
. think whenever class loads loads boolean initial status false
. meet 1 condition,all time, condition meeting now.
when persist, mean need save boolean
state can load storage , check,with boolean
not dependent on initial state false
so in oncreate this
sharedpreference sp = getpreference(0); boolean onclickskip = sp.getboolean("onclick",false);
now can continue; if want save boolean state
editor e = sp.edit(); e.putboolean("onclick",onclickskip); e.commit();
now continue codes
Comments
Post a Comment