Ultimate magazine theme for WordPress.

Single Activity: Why, When, and How (Android Dev Summit '18)

31


With the Navigation Architecture Component, developers have the tools to move towards a single activity structure for their app, but they don’t know:

— why they should move to that model
— when it is appropriate
— how exactly to take advantage of that structure and migrate to it

Navigation Architecture Component →
Testing Fragments →

Presented by: Ian Lake

Android Dev Summit ’18 all sessions playlist →
Subscribe to the Android Channel! →

#AndroidDevSummit


Source: https://blogema.org
Read more all post Android Technology : https://blogema.org/android/
31 Comments
  1. Ian Lake says

    I was really happy to share a lot of the best practices around activities, Fragments, Navigation, and most importantly *making your code testable*. Thanks for watching!

  2. Sofien Rahmouni says

    Good practice in 2016 , then become Bad practice in 2018 … all things with google is strange ..

  3. manideep lanka says

    Why isn't there a simple way to prevent fragment recreation on back pressed?
    Fragment A -> Fragment B. Back button is pressed. Fragment A gets created again. Why? Is there a way to avoid this using the Navigation Component?

  4. ClubLulu says

    Great vid!

  5. Brian Juma Ndiema says

    its been always kotlin these days on your IO presentations. Some of us are still java developers.

  6. Alice Wang says

    Great talk!

  7. Ali kali says

    Thanks

  8. This is WAY more confusing than Multiple Activity Development. Still interested in learning more though.

  9. famke theron says

    Have been using single activity pattern for a while (4 years or so). Banner ads can perform uninterrupted and register more impressions when a single activity pattern is employed.

  10. Radosław Juszczyk says

    What about destroying invisible activities and recreating them when user navigates back to it in order to save memory and resources? Did we stopped to care about that and expect phone manufactures to put more RAM in phones than we used to have in our computers?

  11. Ilya Paskhover says


    36:09 Dynamic Feature Modules
    37:45 Thank you! (summary)

  12. BoxingHacker says

    Very nice, but what's happens when you have a app where some screens have a navbar or drawer and some screens do not? Can you really do the same with one activity

  13. sergej shafarenka says

    Dynamic features must be able to add their graphs at build time rather than been hardcoded in base module. If feature is added to the build, the nav graph of that feature gets added to base nav graph. If feature goes away, the feature's nav graph goes away too.

  14. Ahmed Ali says

    android development is such a pain in the A@#

  15. Fidan Bacaj says

    Its good practice to use two navigation(in two deferents activities ) in same app ?
    example : one navigation for (register ,login) and second navigation for (navigation drawer) ?

  16. Gianluca Recchia says

    Great talk! Can we find some sample app to get an idea of how all the pieces fit together? Sometimes I got lost with the code examples so having a little app to experiment with would greatly help me.

  17. Haobin Li says

    For a real world app that has many screens to follow the Single Activity approach, I can think of two possible scenarios.
    First, a single ViewModel is used and shared by all destinations. This single ViewModel is going to be bloated and not scalable. For this reason, I think the first approach is not suitable for real world development.
    Second, multiple ViewModels are used. (Not necessary one ViewModel per destination but would be close.) Given the lifecycle of a ViewModel is tied to the lifecycle of the (single) Activity, how is a "cold" (instantiated by no longer needed) ViewModel going to be released?

  18. Simon Dakin says

    If you want people to adopt your proposed practices such as only using documentLaunchMode rather than launchMode then perhaps you could write a consistent set of reference and guidance web pages. The current set are almost impossible to comprehend. Best of all is https://developer.android.com/guide/components/activities/tasks-and-back-stack which features a video presented by you and which completely fails to mention documentLaunchMode. And that page was last updated on 28th August 2018!

  19. Patrick Jonas says

    ENJOY THANKSGIVING

  20. Nikhil gunaware says

    Kotlin was the biggest mistake, believe me hybrid mobile application development is way better than kotlin

  21. Coding in Flow says

    MAGICAL~

  22. DeLL116 says

    I'm pretty sure I'm fed up with Android. Been with it since 2009, but I think it's getting to a point where a lot of what I've spent years mastering are getting reworked, and I don't want to go through the struggles of mastering all this new stuff again. Not to mention all the new "gotcha's" that are going to come along with all these new APIs (remember when fragments came along?). Plus, while I'm busy as hell at work, on what do I spend the 30-45 minutes in the day to learn, Kotlin or Flutter?

    You've been good and bad to me, Google. Maybe it's time we spend some time apart.

  23. Rumokimiku says

    Ian's videos are always my favourite 'cause he's always passinote and enthusiastic. Keep up the good work, you're amazing. And thanks for the video.

  24. Faisal Mohammed says

    thanks for effort.
    As a feedback:
    As usual, it turned another Google presentation focused nothing. Atleast, as a developer I was expected to hear in depth about navigation.

  25. Adi Trioka says

    need a codelab for this

  26. Raghunandan Kavi says

    How does this work with when you have app that supports phones and tablet. For example a master detail view on tablet?. In tablet we don't add or replace the fragment as master and detail fragment are side by side. Different navigation graph for phones and tablets??

  27. Peter Keefe says

    Ian's the best. His Udacity courses were great too :-). Now I'm off to bug my manager to make the app single activity haha.

  28. restart 93 says

    hey Ian. quick question about loaders. Old loaders are deprecated, but the new one
    android.support.v4.app.LoaderManager.getInstance(this).initLoader(MY_DETAIL_LOADER_ID, bundle, this);
    is making new request on rotation change. The deprecated version is making request only once.

    So the question is how to make new loader (android.support.v4) make http request only once as deprecated one?

  29. martin seal says

    Picture in picture mode is so broken

  30. Stilgarnaibfremen says

    One of the best videos so far of the Android Dev Summit '18. And probably the best speaker so far too. Clear, concise, to the point and relaxed. Very easy to follow and really well explained. Thanks Ian!!

  31. green6564 says

    Good

Leave A Reply

Your email address will not be published.