How to close all activity before launch new activity from AppWidgetProvider android

51 views Asked by At

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?

1

There are 1 answers

2
snachmsm On BEST ANSWER

you can use finishAffinity() method (from Activity, doc here). launch dummy invisible/transparent Activity, finishAffinity all Activityies and startActivity with proper Intent

there are also some flags for Intents 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);