Hi I want to close all activity before launch new activity from AppWidgetProvider. I'm not having idea to do this. could you please suggest me any idea to do this?
you can use finishAffinity()
method (from Activity
, doc here). launch dummy invisible/transparent Activity
, finishAffinity
all Activity
ies and startActivity
with proper Intent
there are also some flags for Intent
s which should clear your Activity
backstack, but it depends on declared launchMode
in Manifest. you may check these
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
or
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);