App is resuming form a On-click method When I Exit and Reopen It?Android -
i have done 3 pages activity in
- splashscreen
- mainactivity
- results
so here passing value server mainactivity url query string results page on there display results.
i passing this
mainactivity :
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.maina); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar2); setsupportactionbar(toolbar); final button click = (button) findviewbyid(r.id.sc); click.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { mainactivity.this.finish(); //mainactivity.this.finishandremovetask(); intent la = new intent(mainactivity.this, results.class); la.setflags(intent.flag_activity_reorder_to_front); la.setflags(intent.flag_activity_new_task); la.setflags(intent.flag_activity_clear_task); la.setflags(intent.flag_activity_no_animation); startactivity(la); } }); } so display value results. on there have added handler results after 9000ms again mainactivity
results :
new android.os.handler().postdelayed(new runnable() { @override public void run() { results.this.finish(); intent v = new intent(results.this, splashscreen.class); v.setflags(intent.flag_activity_reorder_to_front); v.setflags(intent.flag_activity_new_task); v.setflags(intent.flag_activity_clear_task); v.setflags(intent.flag_activity_no_animation); startactivity(v); } }, 9000); and @ part of main activity have added alert on back-pressed yes/no option exit entire app
mainactivity :
@override public void onbackpressed() { alertdialog.builder alertdialogbuilder = new alertdialog.builder(this); alertdialogbuilder.settitle("do want exit app!"); alertdialogbuilder .setmessage("click yes exit!") .setcancelable(false) .setpositivebutton("yes", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { movetasktoback(true); mainactivity.this.finish(); android.os.process.killprocess(android.os.process.mypid()); system.exit(0); } }) .setnegativebutton("no", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dialog.cancel(); } }); alertdialog alertdialog = alertdialogbuilder.create(); alertdialog.show(); } here it's exiting app when re-open application it's starting results page moving results splashscreen in handler.
here have removed in mainactivity
/* @override protected void onresume() { super.onresume(); }*/ but it's starting results page. can suggest how exit app or how stop resume results page?
update
here problem exit...i giving exit option on pressed
so have 2 scenarios
scenario 1
when launch app start splashscreen --> mainactivity. here exiting app @ mainactivity - it's exiting fine. here exit working fine.
when re-open app after exit, start splashscreen --> mainactivity
scenario 2
it starts same first in mainactivity have button. when click on button, pass url query string intent start results page after 9000ms again go splashscreen --> mainactivity
so here exiting app @ mainactivity
but when re-open app after exit, start results page form , doing handler , again going splashscreen
can suggest missing have given mainactivity oncreate() , onbackpressed()....
there no onresume().. facing same issue scenario2.
try change
from:
mainactivity.this.finish(); to
mainactivity.this.finishandremovetask();
Comments
Post a Comment