exit android application programmatically -
i have 2 activities, first splash activity. know how exit application second activity homepage. i've used method works takes launcher.
public void appexit() { this.finish(); intent intent = new intent(intent.action_main); intent.addcategory(intent.category_home); intent.setflags(intent.flag_activity_new_task); startactivity(intent); }
whenever wish exit open activities, should press button loads first activity runs when application starts clear other activities, have last remaining activity finish. apply following code in ur project
intent intent = new intent(getapplicationcontext(), firstactivity.class); intent.setflags(intent.flag_activity_clear_top); intent.putextra("exit", true); startactivity(intent);
the above code finishes activities except firstactivity. need finish firstactivity's enter below code in firstactivity's oncreate
if (getintent().getextras() != null && getintent().getextras().getboolean("exit", false)) { finish(); }
and done....
Comments
Post a Comment