I have 3 activities. Activity A which leads to activity B, which in turn can go back to activity A or start activity C. However, if I press back in activity C the app should
The following code should do it for you. Almost in all other approaches your app will remain in recent apps. Javadoc can be found at, https://developer.android.com/reference/android/app/ActivityManager.AppTask.html#finishAndRemoveTask()
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
if(am != null) {
List tasks = am.getAppTasks();
if (tasks != null) {
tasks.get(0).finishAndRemoveTask();
}
}