android-activity start from where it closed when I exit the app -
in mainactivity , have code closing application :
@override public void onbackpressed() { if (exit){ intent intent = new intent(intent.action_main); intent.addcategory(intent.category_home); intent.setflags(intent.flag_activity_new_task); startactivity(intent); finish(); super.onbackpressed(); }else { exit = true; new handler().postdelayed(new runnable() { @override public void run() { exit = false; } }, 3 * 1000); }
i should press 2 button when want close application .
the problem ,when close application, starts activity , last activity i've been .
how can start activity mainactivity not other activities ?
use these lines of code..
@override public void onbackpressed() { super.onbackpressed(); if (exit){ intent intent = new intent(intent.action_main); intent.addcategory(intent.category_home); intent.setflags(intent.flag_activity_new_task); intent.addflags(intent.flag_activity_clear_top); intent.addflags(intent.flag_activity_clear_task); intent.addflags(intent.flag_activity_task_on_home); finish(); }else { exit = true; new handler().postdelayed(new runnable() { @override public void run() { exit = false; } }, 3 * 1000); } }
Comments
Post a Comment