【发布时间】:2022-12-27 21:52:08
【问题描述】:
I am trying to navigate back to the login activity after a sign out or deleting a user. Is there a better approach between using intents or using the nav_graph. The pros of the nav_graph is more easily managed navigation code, but how about using intents?
<action
android:id="@+id/action_editProfile_to_loginActivity"
app:destination="@id/loginActivity"
app:launchSingleTop="false"
app:popUpToInclusive="true" />
Opposed to something alike:
val intentCreateProfile = Intent(this@ActivityPhoneAuthentification, ActivityCreateProfile::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY or Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(intentCreateProfile)
finish()
【问题讨论】:
-
It is only very recently that the nav graph even supports navigating to activities. So it is too early for a convention or general best practice to have emerged.