Ниже мой код;
навигация. xml
<fragment android:id="@+id/HomeFragment"
android:label="Home Screen">
<action
android:id="@+id/action_activeRefillDeviceFragment_to_loginFragment"
app:destination="@id/loginFragment"
app:popUpTo="@id/loginFragment"
app:popUpToInclusive="true"/>
</fragment>
<fragment android:id="@+id/loginFragment"
android:name="com.example.dprefilldevice.login.fragment.LoginFragment"
android:label="LoginFragment">
<action android:id="@+id/action_loginFragment_to_activeRefillDeviceFragment"
app:destination="@id/activeRefillDeviceFragment"
app:popUpTo="@id/loginFragment"
app:popUpToInclusive="true"/>
</fragment>
Событие нажатия кнопки выхода из системы;
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.logout -> {
Utils.getPreferrence(context)?.edit()?.clear()?.apply()
findNavController().navigate(R.id.action_activeRefillDeviceFragment_to_loginFragment)
}
}
return super.onOptionsItemSelected(item)
}