Issue
So, like the title says I'm trying to retrieve passed arguments from a bundle according to the documentation I'm following by using var args = GameWonFragmentArgs.fromBundle(arguments!!)
.
But Android Studio suggests using the following code:
var args = GameWonFragmentArgs.fromBundle(requireArguments())
I looked up the Android Documentation for Fragment and found that requireArguments()
returns a @NonNull Bundle or an IllegalStateException. Why does Android Studio suggest using it and what's the difference between the two?
Also, I couldn't find relevant documentation about fromBundle()
.
Solution
There is some api changes in androidx.fragment:fragment
requireArguments() --- method which returns a @NonNull Bundle or throws an IllegalStateException.
fromBundle(arguments!!) --- these case App may be crashed because of Null pointer exception. if arguments is null app will be crashed.
Answered By - sasikumar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.