Navigation destination is unknown to this NavController?
You declare an action just for navigating from HomeFragment
to SettingsFragment
. This action can only be used with HomeFragment
as a starting point, so for other Fragment
s you get the Exception "{actionId} is unknown to this NavController".
Since you need to navigate to SettingsFragment
from several starting points, you can declare a global action
<action android:id="@+id/action_global_settingsFragment"
app:destination="@id/settingsFragment"/>
IllegalArgumentException: Navigation action/destination cannot be found from the current destination Destination [Navigation Error]
You need to add only JobsFragment
in your nav graph and add action in this fragment for PrivsDetailFragment
.
<fragment
android:id="@+id/jobsFragment"
android:name="com.gazelle.wadifatk.jobLists.jobsFragment"
android:label="الوظائف"
tools:layout="@layout/fragment_jobs" >
<action
android:id="@+id/action_jobsFragment_to_govSectionFragment"
app:destination="@id/govSectionFragment" />
<action
android:id="@+id/action_jobsFragment_to_latestNewsFragment"
app:destination="@id/latestNewsFragment" />
<action
android:id="@+id/action_jobsFragment_to_privsDetailFragment"
app:destination="@id/privsDetailFragment"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim" />
</fragment>
And then in you adapter, using this action:
PushDownAnim.setPushDownAnimTo(holder.card_view)
//.setScale(PushDownAnim.MODE_SCALE, 0.89f)
.setOnClickListener {
val sendData = JobFragmentDirections.actionJobFragmentToPrivsDetailFragment(priv_list[position])
Navigation.findNavController(view).navigate(sendData)
}
You can remove privSectionFragment
from the nav graph.
Avoiding Android navigation IllegalArgumentException in NavController
You can use the below code before navigating to check whether the current destination is correct or not. This will make sure that the call happens from the current fragment only. This issue can be reproduced by clicking on two views simultaneously(Two items in a list).
if (findNavController().currentDestination?.id == R.id.currentFragment) {
findNavController().navigate(R.id.action_current_next)
}
Related Topics
How to Set Internet Options for Android Emulator
Asynctask and Looper.Prepare() Error
Android - Set Text to Textview
Scan_Results_Available_Action Return Empty List in Android 6.0
How to Integrate Opencv Manager in Android App
How to Programmatically Add Buttons into Layout One by One in Several Lines
Execution Failed for Task 'App:Mergedebugresources' Crunching Cruncher....Png Failed
Trigger Mediascanner on Specific Path (Folder), How To
Bluetooth Low Energy Startscan on Android 6.0 Does Not Find Devices
Passing String Array Between Android Activities
Android: How to Pass Parcelable Object to Intent and Use Getparcelable Method of Bundle
Is There a Real Solution to Debug Cordova Apps
Edittext, Clear Focus on Touch Outside
Connectivitymanager.Connectivity_Action Deprecated