Safe Args with Navigation Component - Android Studio Tutorial

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 73

  • @guyyakobovich9873
    @guyyakobovich9873 4 года назад +7

    This is the best, short, straight to the point explanation I have seen on the subject.
    Thank you very much, you earned a new supporter

  • @MrDoge-yp8us
    @MrDoge-yp8us 3 года назад +2

    After half a day looking to solve my problem, you saved me. Thank you!

  • @christianmethot5941
    @christianmethot5941 4 года назад +2

    Thank you so much! You have no idea how your tutorials have helped us, making easy tasks that looked daunting and impossible. All the best.

    • @StevdzaSan
      @StevdzaSan  4 года назад

      Thank you Christian, I'm happy for that! 😊

  • @pawechilczuk7559
    @pawechilczuk7559 3 года назад

    Great explanation! I got stuck in one point, couldn't see ...FragmentArgs class - and saw in video, just need to rebuild project. Thanks a lot!

  • @lucye7320
    @lucye7320 4 года назад +1

    Really great tutorial, super concise. Thank you!

  • @ehtishamhassan8146
    @ehtishamhassan8146 4 года назад +1

    Very helpful tutorial.
    Thank You.

  • @xtanion
    @xtanion 3 года назад +1

    Thank You, Thanks for making these amazing videos

  • @tarsilacostalonga
    @tarsilacostalonga 4 года назад +2

    Hi, Stevdza.
    Great video, right to the point.
    Is there a video example showing how to pass more than 1 value with safe args?
    I would really appreciate this, because i'm struggling with this issue on my project.
    Thank you so much!!

    • @StevdzaSan
      @StevdzaSan  4 года назад +2

      You can pass multiple values using Array as a type, or your own data class as parcelable. I'll make a video about it in the future.

    • @tarsilacostalonga
      @tarsilacostalonga 4 года назад

      @@StevdzaSan Thank you, I apreciate that, I will be awaiting the video!! hahah

  • @aelafdev
    @aelafdev 4 года назад

    clear concise and to the point!!!

  • @wearedoingsomething
    @wearedoingsomething 3 года назад +1

    Stefane brate zivio sto godina!!! Ovo mi treba!! Imas li ono nesto tipa buyMeCoffee ili patreon ? Zasluzio si pivo ili dva ili kafu, štagod ti više paše :D

  • @pratikchauhan989
    @pratikchauhan989 3 года назад

    Amazing one Thankyou for this one

  • @noorullah5748
    @noorullah5748 2 года назад

    Thank you so much. It really helped

  • @unitubetv
    @unitubetv Год назад

    Very useful tutorial, thank you Stevdza-San

  • @noshingh521
    @noshingh521 4 года назад

    Thank you. that was Very helpful

  • @quybuihai7041
    @quybuihai7041 2 года назад +1

    the Gradle version is new so I don't know how to add Safe Args. Can you help me?

  • @chetanprajapati3085
    @chetanprajapati3085 3 года назад

    Great Tutorial

  • @bro_chenzox
    @bro_chenzox 4 года назад +1

    What happened before the creation of the video, what resource gave an understanding of the topic especially for you, it is obvious that it was of high quality ?! Could you share? P.S. Subscribed

    • @StevdzaSan
      @StevdzaSan  4 года назад

      Android documentation and practice.

    • @bro_chenzox
      @bro_chenzox 4 года назад

      @@StevdzaSan Thanks, I have checked that, it's true. But at the moment 3:38 can we use `val args = SecondFragmentArgs.fromBundle(arguments!!)` or it is old decision?

  • @Mtorres1889
    @Mtorres1889 3 года назад +2

    my app dont generate de clasess, do you know why?

    • @deanuziel4545
      @deanuziel4545 2 года назад

      Make sure you’ve implemented the safeArgs inside build.gradle

  • @aliappdevelop
    @aliappdevelop 3 года назад

    Awesome tutorial but I have one question. What if I need to pass two parameters insted of one. Like Integer as well as String. Without passing object. It is possible??

  • @ronneyismael605
    @ronneyismael605 3 года назад

    You explain really great. Please make a video on MVVM Architecture.

  • @sudheeshmohan4357
    @sudheeshmohan4357 Год назад

    Good tutorial! 👍

  • @poonammishra6276
    @poonammishra6276 2 года назад

    Nice Explanation, I have one question though how to pass an object by using safe arg?

  • @platinumphonesandcomputers
    @platinumphonesandcomputers Год назад

    Am having challenges syncing the dependencies

  • @brandondelacruz934
    @brandondelacruz934 4 года назад +2

    Ive been having this problem where safeArgs arent working. Even tho its enabled in my gradle file

    • @StevdzaSan
      @StevdzaSan  4 года назад +1

      Rebuild your project, or close and run Android Studio again after you have synced your project.

  • @rafidnagaradharmakusuma3487
    @rafidnagaradharmakusuma3487 2 года назад

    sir how to pass image from first fragment to second fragment , in your example you use int to pass the number

  • @Alexwith
    @Alexwith 3 года назад

    Hey, man, thanks! You are cool! Im from Belarus and i dont know English, but im anderstand you and im anderstent how do what you tell!!!! Thanks, man!!!!

  • @TriNguyen-ym3hf
    @TriNguyen-ym3hf 4 года назад

    i have a question, why do we use safe args if we have viewmodel-liveData ?. thanks

  • @arkamondal6160
    @arkamondal6160 4 года назад

    Sir, can you tell how to maintain the app menu using navigation component

  • @Android-sb8uo
    @Android-sb8uo 4 года назад

    I followed all of your guidelines even the documentation but I still get this error: Android linking resource failed, AAPT: error: failed writing to 'directory\project\app\build\intermediates
    untime_symbol_list\debug\R.txt': The data is invalid. (13).
    What does it mean? how to fix that?

  • @h.r.60
    @h.r.60 4 года назад

    So... should I be using fragments instead of activities now? How do they act with the application's main thread?

    • @StevdzaSan
      @StevdzaSan  4 года назад +1

      Navigation component is well structured and easy to use. Using fragments with just one activity is one of the main purposes of nav component. Btw more videos coming about nav component.

  • @ampo2004
    @ampo2004 3 года назад

    Do you sell courses or personalized tutoring? I really like the way you teach, simple, concsice and very good!

  • @codingmafia1642
    @codingmafia1642 4 года назад

    Great Video ,so how do I pass a value from Navigation MainActivity to any Fragments I switch to

    • @StevdzaSan
      @StevdzaSan  4 года назад

      Solution: your MainActivity should not contain anything except NavHostFragment. Use your fragments to handle everything else.

    • @codingmafia1642
      @codingmafia1642 4 года назад

      @@StevdzaSanThank u vm,
      but my real problem statement, I m selecting a user role from first Activity--->carry role value as an intent to MainActivity(comes with Navigation drawer side menu + fragments(home,gallery... etc) by default) and I m trying to pull the role from MainActivity to any Fragments that I switch to.
      I tried to the following in MainActivity where Navcontroller is setted.
      bundle.putString(...);
      NavController.setGraph(R.navigation.mobile_navigation,bundle);
      On receiving Fragments
      String role = getArguments.getString("role");
      Only recieving the role onStartDestinationFragment which is Home but in others fragments(gallery,profile etc...) i m receiving null value.
      I tried safeArgs ,Bundles I still receiving null value of role when in other Fragments.
      🙏Hope I m clear

  • @mauriciopriego1700
    @mauriciopriego1700 3 года назад

    thank you

  • @olamao
    @olamao 3 года назад

    Thanks a lot. I am having problems when trying to define val args : SecondFragmentArgs by navArgs(). The error says: "property delegate must have a getvalue". However I noticed that android didn´t generate the three classes (two for directions and one for arguments). Do you have any suggestion for me, please?

  • @TheGoodOldDays-IsNow
    @TheGoodOldDays-IsNow 5 месяцев назад

    This worked 4 years ago, but it doesn't in 2024. I'm an experienced programmer, but totally new to Android. Can anyone point me in the right direction? the structure of the gradle.build files has completely changed in the meantime and something as simple as setting "classpath" gives an error.

  • @theai2020
    @theai2020 2 года назад

    even after adding toString the app crashes there is something wrong with the code

  • @waleefalrooh8
    @waleefalrooh8 3 года назад +2

    The safearga doesnot genarate the classes🥲

    • @StevdzaSan
      @StevdzaSan  3 года назад

      Rebuild your project

    • @waleefalrooh8
      @waleefalrooh8 3 года назад

      @@StevdzaSan i cleaned it and rebuild it so many times but still the same proplem

    • @StevdzaSan
      @StevdzaSan  3 года назад

      @@waleefalrooh8 Check your dependencies and plugin.

    • @waleefalrooh8
      @waleefalrooh8 3 года назад

      @@StevdzaSan i checked it now it is in the project but it's not in the java (generated) file.. i don't know where it is though

    • @StevdzaSan
      @StevdzaSan  3 года назад

      @@waleefalrooh8 Strange, you should ask on stackoverflow then..

  • @mdjahidulislam9205
    @mdjahidulislam9205 4 года назад

    Dont understand the (by navargs) syntax , would you explain please

    • @StevdzaSan
      @StevdzaSan  4 года назад +3

      That's a property delegate. We are lazily getting arguments during variable declaration. Something similar to "by lazy {}".
      Classes with postfix "Args" and "Direction" are automatically generated by Safe Args plugin.

    • @mdjahidulislam9205
      @mdjahidulislam9205 4 года назад

      @@StevdzaSan thanks a lot.

  • @mohammadazrikhairuddin8753
    @mohammadazrikhairuddin8753 3 года назад

    I don't know why after I sync my project, the project that was supposed to be generated automatically is not there. Do you know the reason?

  • @layly7961
    @layly7961 3 года назад +1

    Hello dears. I can't generate fragment direction in my project. Do you have any solutions? I have add class path and apply plugin but still not working.

    • @MiYakudzik
      @MiYakudzik 3 года назад

      I have the same problem. Did you find solution?

    • @layly7961
      @layly7961 3 года назад

      @@MiYakudzik it's already generated but just didn't show on that folder. You should declear your fragment direction as my example. Ex: val direction: FragmentDirection =

    • @layly7961
      @layly7961 3 года назад

      @@MiYakudzik and also if your project is java you should declear FragmentDirection f =

    • @layly7961
      @layly7961 3 года назад +1

      @@MiYakudzik it will show your generated direction after you declear this variable.

    • @MegaRockandroll09
      @MegaRockandroll09 2 года назад

      @@layly7961 Thank you so much. I almost gave up thinking the plugin is bugged

  • @vitquack4078
    @vitquack4078 2 года назад

    Gradle dependency for SafeArgs is outdated

  • @Techydom
    @Techydom 2 года назад

    PLEASE SOMEONE SHOULD HELP HAVE RESEARCHED MY ASS OUT AND CANT FIND THE SOLUTION I RAN INTO THESE NAVCONTROLLER ERROR

    • @Techydom
      @Techydom 2 года назад

      THE APP JUST EXITS WITH THIS ERRORS

  • @amandasjoberg463
    @amandasjoberg463 9 месяцев назад

    how do I fix safeargs for java? My build.gradle file doesn't have a buildscript section, and my dependencies don't contain any classpaths
    I added the following to build.gradle(project): id("androidx.navigation.safeargs") version "2.5.3" apply false
    and id ("androidx.navigation.safeargs") in build.gradle(module).
    When I write
    the text of myArg is red. Something's wrong but I don't know what.
    Also in my java file (FirstFragment), how do I navigate to SecondFragment and send my data?
    Currently I navigate this way:
    NavHostFragment.findNavController(FirstFragment.this)
    .navigate(R.id.action_FirstFragment_to_SecondFragment);
    But I have a variable int count, and I want to send the value of it as myArg. How do I do that?