i working on splash screen test , implemented click listener layout can skipped clicking on screen. problem intent called twice, because loading thread not interrupted when screen clicked. doing wrong , how avoid error?
public class splashscreen extends activity { final thread loading = new thread(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setrequestedorientation(activityinfo.screen_orientation_portrait); setcontentview(r.layout.splashscreen); imageview splashscreenview = (imageview) findviewbyid(r.id.splashscreenanimation); splashscreenview.setbackgroundresource(r.drawable.flashscreenanimation); animationdrawable splashscreenanimation = (animationdrawable) splashscreenview.getbackground(); splashscreenanimation.start(); relativelayout ontouchskipscreen = (relativelayout)findviewbyid(r.id.splashscreenview); ontouchskipscreen.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { loading.interrupt(); loading.isinterrupted(); intent splashscreen = new intent(splashscreen.this, homescreen.class); startactivity(splashscreen); overridependingtransition(r.anim.fade_in, r.anim.fade_out); finish(); } }); thread loading = new thread() { public void run() { 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(); } } }; loading.start(); } }
go it
public class splashscreen extends activity { thread loading ; boolean flag = true; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setrequestedorientation(activityinfo.screen_orientation_portrait); setcontentview(r.layout.splashscreen); imageview splashscreenview = (imageview) findviewbyid(r.id.splashscreenanimation); splashscreenview.setbackgroundresource(r.drawable.bontactbook); animationdrawable splashscreenanimation = (animationdrawable) splashscreenview.getbackground(); splashscreenanimation.start(); relativelayout ontouchskipscreen = (relativelayout) findviewbyid(r.id.flashscreenanimation); ontouchskipscreen.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { flag = false; intent splashscreen = new intent(splashscreen.this, homescreen.class); startactivity(splashscreen); finish(); } }); thread loading = new thread() { public void run() { try { sleep(5000); if (flag) { 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(); } }
Comments
Post a Comment