Android Architecture Components : LiveData

Live Data : Life-cycle aware Observables

As an Android developer you often have to work with data that is dynamic and changing with user input, device configuration changes, or even time changes. On top of this as a developer you have to respect the life-cycle of an Activity of Fragment that contains this dynamically changing data: stop updates onStop() or onPause() and restart the updates onStart() and onResume(). Examples of this is location data, countdown timers, user's list selections and any other type of dynamically changing data. Lets see how we can make these tasks easier using LiveData. We will demonstrate LiveData by creating a self contained timer.

Subclass LiveData

LiveData object is set active when the observer's lifecycle is stated or resumed. And the LiveData object is set inactive when the observer's lifecycle is stopped or pause. In our TimerLiveData we start timer when onActive() is called and stop the timer when onInactive() is called. This way the observer only gets timer updates while it is active.

Observe with LifecycleOwner

Instantiate the TimerLiveData object and then observe() in order to get callbacks on timer's value changes but only while our Activity is active.

Benefits of using LiveData

  • Makes objects life-cycle aware
  • Keeps LiveData objects self contained
  • Keeps Activitys and Fragments clean
  • Eliminates memory leaks as LiveData objects clean up themselves.
  • Observers instantly notified of value changes in LiveData


  1. Very interesting and useful presentation to understand the architecture of Android. Thank you.

    Best Android Training institute in Chennai
    Android Classes in Chennai

  2. You’ve written a really great article here. Your writing style makes this material easy to understand.. I agree with some of the many points you have made. Thank you for this is real thought-provoking content
    Python training in bangalore
    Python course in pune
    Python training in bangalore

  3. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.

    rpa training in chennai
    rpa training in bangalore
    rpa course in bangalore
    best rpa training in bangalore
    rpa online training

  4. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    Best Devops Training in pune
    excel advanced excel training in bangalore
    Devops Training in Chennai

  5. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
    Best AWS Training in Chennai | Amazon Web Services Training in Chennai
    AWS Training in Bangalore | Amazon Web Services Training in Bangalore
    Amazon Web Services Training in Pune | Best AWS Training in Pune

  6. Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
    If you are looking for any Big data Hadoop Related information please visit our website Big Data Hadoop Training In Bangalore page!

  7. Excellent information with unique content and it is very useful to know about the information based on blogs...
    salesforce Training in Bangalore
    uipath Training in Bangalore
    blueprism Training in Bangalore

  8. Informative post indeed, I’ve being in and out reading posts regularly and I see alot of engaging people sharing things and majority of the shared information is very valuable and so, here’s my fine read.
    click here to enable adobe flash player
    click here
    visit here
    check it out
    visit for more

  9. Good post!Thank you so much for sharing this lovely article.It was so good to read and useful to upgrade my understanding...
    salesforce Training in Bangalore
    uipath Training in Bangalore
    blueprism Training in Bangalore

  10. Subscription boxes are a type of boxes which are delivered to the regular customers in order to build goodwill of the brand. They are also a part of the product distribution strategy. As a woman, you should subscribe to these boxes to bless yourself with a new and astonishing box of happiness each month. visit mysubscriptionsboxes

  11. Great Article. Thank you for sharing! Really an awesome post for every one.

    IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

    JavaScript Training in Chennai

    JavaScript Training in Chennai

  12. Thanks for sharing your innovative ideas to our vision. I have read your blog and I gathered some new information through your blog. Your blog is really very informative and unique. Keep posting like this. Awaiting for your further update.If you are looking for any Data science related information, please visit our website Data science training institute in btm layout

  13. Really i appreciate the effort you made to share the knowledge. The topic here i found was really effective...

    Start your journey with Best SAP Course and get hands-on Experience with 100% Placement assistance from experts Trainers @Softgen Infotech Located in BTM Layout Bangalore. Expert Trainers with 8+ Years of experience, Free Demo Classes Conducted.

  14. It's such a superb and helpful post..
    Thanks for sharing with us,
    We are again come on your website,
    Thanks and good day,
    If you need any logo then,
    Please visit our site,

  15. thanks for posting useful information.You have provided an nice article, Thank you very much for this one.Promobuddy is one of the best Digital Marketing Company in Ghaziabad experts in India.
    If you want to grow your Business Online, For more information, please visit our website:Digital Marketing Company in Ghaziabad
    SMM Services,
    PPC Services,
    SEM Services,
    Best Web Designing Company in India

  16. This is an excellent and helpful information...

  17. Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.share somemore coding related to this program...
    AngularJS training in chennai | AngularJS training in anna nagar | AngularJS training in omr | AngularJS training in porur | AngularJS training in tambaram | AngularJS training in velachery

  18. Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information speciall development I care for such info a lot.
    Java training in chennai | Java training in bangalore | Java training in hyderabad | Java training in coimbatore | Java training in online

  19. Great Article
    Cloud Computing Projects

    Networking Projects

    Final Year Projects for CSE

    JavaScript Training in Chennai

    JavaScript Training in Chennai

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  20. Insightful! This article has a great content. Very well structured and written. It is very precise and easy to understand. thanks for sharing it. It is very insightful and thoughts are appreciated.
    Selenium Training in Chennai

    Selenium Training in Velachery

    Selenium Training in Tambaram

    Selenium Training in Porur

    Selenium Training in Omr

    Selenium Training in Annanagar

  21. I am sure this post has helped me save many hours of browsing other related posts just to find what I was looking for. Many thanks!
    amazon web services aws training in chennai

    microsoft azure course in chennai

    workday course in chennai

    android course in chennai

    ios course in chennai

  22. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    salesforce course in chennai

    software testing course in chennai

    robotic process automation rpa course in chennai

    blockchain course in chennai

    devops course in chennai

  23. The Blog contains the effective and attractive information’s and thanks for the blog.
    JAVA Training in Chennai
    JAVA Training in Bangalore

  24. Very nice blog, with a lot of new information. Thanks for sharing the wonderful blog. Keep going on.
    Ubs accounting
    Myob Singapore
    Best Accounting software Singapore

  25. Online casino in Kerala - KDAL - KDAL
    Online หาเงินออนไลน์ casino in Kerala is the new online casino that launched in 2018 by Kambal. 제왕 카지노 This new casino aims to ensure that the best 온카지노 entertainment for players is

  26. This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article. bitmain antminer l7

  27. Whatsapp Number Call us Now! 01537587949
    It Training In Dhaka
    USA pone web iphone repair USA
    USA SEX WEB careful
    bd sex video B tex
    bd sex video sex video
    bd sex video freelancing course

  28. Thank you for sharing such a nice and interesting blog and really very helpful article.
    Oracle Recruiting Cloud Training

  29. DJay Pro AI Crack is a revolutionary technology to deconstruct and mix music in real-time. Instantly isolate beats, instruments.Djay Pro Mac Crack

  30. Best Manifestation Books · Super Attractor · Manifest Your Destiny · Ask and It Is Given · The Power of Now · You Can Heal Your Life · The Magic of Manifesting.Best-Manifestation-Books

  31. Tea TV is an entertainment application that allows users to stream movies and TV shows on their mobile devices. It offers premium features, such as ad-free streaming, access to exclusive content, and high-quality video playback, without requiring users to pay a subscription fee.


Post a Comment

Popular posts from this blog

Building a Cryptocurrency with Kotlin : Part 1

Android Data Binding : Dynamic RecyclerView Adapter