I have a case here that I have to open a Fragment from an Activity and I did it sometimes but the issue here that I wanna open the Fragment that has an argument with it.
<fragment
android:id="@+id/productDetailsFragment"
android:name="com.a.ry.ui.product.ProductDetailsFragment"
android:label="fragment_product_details2"
tools:layout="@layout/fragment_product_details" >
<argument
android:name="productId"
app:argType="integer" />
</fragment>
What I know is that I can open a Fragment (From Activity) and pass its Argument like this:
val bundle = Bundle()
bundle.putInt("productId", productIdValue)
navController.navigate(R.id.productDetailsFragment, bundle)
the problem is here "productId" what if another developer change that name from navigation.xml file so it's not the best practice at all
I want to take the same reference of that argument name.
Or if there is another solution for that?