Questions tagged [android-safe-args]

144 questions
2
votes
1 answer

Why can't I get null as an argument when switching screens in navigation?

I use navigation and SafeArgs to switch screens and pass data. When data is selected on screen A, data is transmitted at the same time as screen switching. However, there are times when screen A switches to screen B without any action. I decided to…
2
votes
3 answers

I cannot set Safe Args default value

I have a String type arg send from NewCodeFragment to MainFragment. If I set a default value, then I got a 'too many args' error. How can I set a default value? My understanding is if I send a arg, then the destination fragment will receive the arg,…
caibirdcnb
  • 275
  • 5
  • 18
2
votes
0 answers

Cannot call onResume/onPause when using navigation with dialog(BottomSheetDialogFragment)

Sorry if the naming is bad, but, there are too many things, so had to change the names. But I am having an issue with navigation. I have a nav_graph as following.
2
votes
2 answers

Navigating with safeArgs in Kotlin throws and error

I have a fragment that can be either navigated to via a bottom navBar without arguments or from a different fragment with arguments. The navigation itself works perfectly fine but as soon as I add my arguments it crashes. I'm unsure how much code is…
Oliver
  • 117
  • 2
  • 15
2
votes
1 answer

error on generateSafeArgsDebug task execution, XmlPullParserException only whitespace content allowed

I had a project in which had three navigation graph xml files, than I deleted one file from file explorer window, after that I had a problem with building the project. FAILURE: Build failed with an exception. * What went wrong: Execution failed for…
2
votes
1 answer

Which is the better way to share data between Fragments?

I want to share a few Integer values from one fragment to the other. I don't want lose the data when the device changes configuration. So the two ways that I came across and want to know which one will be better for my use case are: 1. Sharing a…
2
votes
1 answer

How to add shared element transition when navigating from recycler view to a fragment while using navigation components and safeArgs?

I want to show shared element transition from my recycler view to a fragment class, I've wriiten the following code: holder.view.setOnClickListener { val extras = FragmentNavigatorExtras( holder.view.ivPersonImage to…
2
votes
1 answer

unable to pass data from fragment to tablelayout using safe Args in android jetpack

I want to pass data from fragment to tablayout but its returning null value. tablayout consist of 2 fragments as shown in figurethis is my tablayout i have tried to to pass data from tablayout to fragment and its working but i dont know why…
shivam
  • 33
  • 5
2
votes
0 answers

Navigation safe args issue on navigating back to fragment

I am using Navigation and safe arg to redirect user from fragment A to B. Fragment B further redirects user to fragment C based on the arguments passed from A to B. Now problem is when I am pressing back from fragment C fragment B gets recreated but…
HemangNirmal
  • 621
  • 1
  • 8
  • 24
2
votes
2 answers

android NavDirections constructor with arguments not generated

I am uisng Android Jetpack Navigation framework with native java. The thing is the compiler automatically generates the class responsible for the actions defined in the navigation graph, with the correspondent argument setters and getters, but it is…
2
votes
3 answers

FragmentDirections was not generate by Safe Args plugin

When I trying to use Safe Args plugin to jump from one fragment to another, the compiler shows "Unresolved reference: VideoFragmentDirections". I have already set the classpath and dependency for safe args and VideoFragmentArgs was generated…
Lee Nicolas
  • 21
  • 1
  • 2
2
votes
1 answer

Check if arguments exists when navigating to Fragment using SafeArgs

I migrated to Navigation Components and since I use Fragments now, I do no longer call onActivityResult() in my Fragment. I defined the arguments that I pass to AddEditTaskFragment and want to send the modified arguments back to the TodayFragment.…
Andre Thiele
  • 3,202
  • 3
  • 20
  • 43
1
vote
1 answer

How is safe args in navigation component type safe (Android)?

In a normal fragment transaction we would pass data as: Fragment fragment = new Fragment(); Bundle bundle = new Bundle(); bundle.putInt(key, value); fragment.setArguments(bundle); Isn't this type safe too? So what does it mean when we say that…
1
vote
1 answer

java - error: cannot find symbol . in generated classes SomeDirections.SomeAction

I am implementing navigation between Fragments from different flows (single-activity architecture with flow fragments) meaning from one nested graph to another. I am trying to pass one testID argument using Safe Args. In my origins Fragment I use…
1
vote
0 answers

How to retrieve Parcelable objects in fragments correctly?

In a fragment, override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) var args = arguments args?.getParcelable("jar").let { viewModel.setJar(it as…