android - How to exit an application ,close all the activtiy and show the home screen? -
this question has answer here:
- how exit application , show home screen? 17 answers
i had wandered in web hour , hour, couldn't able find code closes app , closes activities return home screen.even though "exit' button indispensable android app couldn't find perfect code job.i giving codes didn't work.so please don't suggest that.
intent intent = new intent(intent.action_main); intent.addcategory(intent.category_home); intent.setflags(intent.flag_activity_new_task); startactivity(intent);
this code closes app , shows homescreen.but didn't close running app.it minimises app
activity.finish(); system.exit(0); protected void quit(){ process.killprocess(process.mypid()); }
this code restarts current activity
this might work:
android.os.process.killprocess(android.os.process.mypid()); system.exit(0);
or call movetasktoback(true)
on activity instead of system.exit()
. hide application until user wants use again.
remember, long you're responding lifecycle events appropriately, neither nor user needs care if application still running or not.
so if want hide application call movetasktoback()
, let android decide when kill it.
Comments
Post a Comment