您可以使用从F到C的标志intent.FLAG_ACTIVITY_CLEAR_TOP构建一个intent.然后您必须使用intent调用startActivity()并触发它以发生onBackPressed或类似的东西.
Intent i = new Intent(this,C.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i)
FLAG_ACTIVITY_CLEAR_TOP将执行的操作是返回堆栈上最新的活动C实例,然后清除其上方的所有内容.但是,这可能会导致重新创建活动.如果要确保它与活动的实例相同,请同时使用FLAG_ACTIVITY_SINGLE_TOP.从文档:
The currently running instance of activity B in the above example will
either receive the new intent you are starting here in its
onNewIntent() method,or be itself finished and restarted with the new
intent. If it has declared its launch mode to be “multiple” (the
default) and you have not set FLAG_ACTIVITY_SINGLE_TOP in the same
intent,then it will be finished and re-created; for all other launch
modes or if FLAG_ACTIVITY_SINGLE_TOP is set then this Intent will be
deliver