Published on 11/27/2017 9:25 am
#Components of #Android #Architecture and #Howto Use Them


We know the old android architecture components like Linux kernel, native libraries, android runtime, application framework, and applications.

Google has launched 14 different versions of android OS but one thing to notice is that there was not a good architecture to follow or to maintain your code better. But in now Google I/O has announced a new Android Architecture components that will help us to maintain our code robust, testable, maintainable and easily readable. The new pattern announced by Google is MVVM i.e model view view-model pattern that is reactive and removes lots of boiler plate codes.

Android Architecture Components

There are 4 components now:

  • Live Data
  • View Model
  • Life Cycle
  • Room

Let’s see all one by one.

1. Live Data

Live data is just an observable data holder that notify observer about the data changes so that we can update the UI easily.

Live data can be of any type like this:

LiveData> myLiveData;

Live data works with Lifecycle component to check the current state of activity like on screen, off screen or destroy so live data update UI only when activity is visible.

2. Life Cycle

We know that live data send an update to UI only when activity is not off screen or destroy. Live data uses 2 lifecycle interfaces for this, that is LifeCycleOwner and LifeCycleObserver.

LifeCycleOwner: These are the fragments or activities.

LifeCycleObserver: This is Lifecycle observer that observe lifecycle owner.

3. View Model

View Model are objects that holds live data and other data for UI and also control configuration changes.

Read Full Blog Here>> What are New Android Architecture Components and How to Use Them

0 Comments
Please login to post your comment..