I am sending a raw JSON as a String in URI navigation with Navigation library. It looks like this.
findNavController().navigate(
Uri.parse("android-app://androidx.navigation/checkout/${Gson().toJson(orderSummary)}"),
NavOptions.Builder()
.setEnterAnim(R.anim.transition_slide_in_right)
.setExitAnim(R.anim.transition_slide_out_left)
.setPopExitAnim(R.anim.transition_slide_out_right)
.setPopEnterAnim(R.anim.transition_slide_in_left)
.build()
)
}
and then I retrieve it like so
arguments?.getString(key)
This works as expected expect for one test case - special chars are not decoded when retrieving the json (specifically % sign)
So when checking the value of this Uri.parse("android-app://androidx.navigation/checkout/${Gson().toJson(orderSummary)}")
, it looks as expected contains the % sign but when doing arguments?.getString(key)
the % sign is replaced with ?
for an unknown char.
How to keep the special chars when getting the string from the arguments?