I am stuck in this issue of back navigation button for long while, I have tried different methods but still the problem is not resolved
Here is the IMAGE
This is my issue
- So, I have a home screen where i am signing up and login the user
- If the user is already logged in I have set nav graph to go to the dashboard
- Now when the person is redirected the home screen is showing the back button
- I have tried nav controller, tried to change the start destination id, but still nothing worked
Here are some codes
Defined in SelectLanguageFragment
private fun checkUserExist(){
val currentUser = auth.currentUser
val navOptions: NavOptions = NavOptions.Builder()
.setPopUpTo(`in`.jadu.anjuconsumerapp.R.id.consumerHomeFragment, true)
.build()
if(currentUser != null){
findNavController().navigate(`in`.jadu.anjuconsumerapp.R.id.action_selectLanguageFragment_to_consumerHomeFragment)
}
}
Tried navOptions but didn't worked
NavGraphCodes
app:startDestination="@id/selectLanguageFragment"
<fragment
android:id="@+id/selectLanguageFragment"
android:name="in.jadu.anjuconsumerapp.consumer.commonuis.SelectLanguageFragment"
android:label="Select Language" >
<action
android:id="@+id/action_selectLanguageFragment_to_phoneVerificationFragment"
app:destination="@id/phoneVerificationFragment" />
<action
android:id="@+id/action_selectLanguageFragment_to_consumerHomeFragment"
app:destination="@id/consumerHomeFragment"
app:popUpTo="@id/selectLanguageFragment"
app:popUpToInclusive="true" />
</fragment>
I have tried getSupportActionBar().setDisplayHomeAsUpEnabled(false)
but i didn't need this i just want to remove it from the navigation,
So after struggling a lot watched a lot many yt videos, github I finally got the solution from androidx Docs Reference
So, When we are setting up the navigate up ...
Top Level Ids
will not have the back arrowcode
Here i have declared both the fragments (selectLanguage,farmerDashboard) as top level so that i would not get the back button on these ids the rest app works fine ...
So , this was a simple thing
Hope this helps you :)