To clear top activities from stack use below code
Intent intents = new Intent(A.this, B.class);
intents.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TOP
| IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intents);
finish();
It will delete all activities from stack either asynctask run or not in the application.
It works fine and also a good approach
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…