Posts

All about ViewModel and Its working.

Image
Hello friends hi. This post is regarding all about the ViewModel and It's working.  Well, ViewModel is the part of the MVVM ( Model-View-ViewModel ) architectural  pattern. The  ViewModel  class is a  business logic or screen level state holder . It exposes state to the UI and encapsulates related business logic. In more simple words, ViewModel is used to persist the state on configuration changes like Screen Rotation, Keypad show or hide etc. It's a lifecycle aware component which means it work with respect to the lifecycle of an Activity or Fragment. Because it associated with Views as shown in following... As we can see that the onCleared() method of the ViewModel is invoked just before the onDestroy() method of the Activity.  The tasks which are no longer need in the memory is usually written in the onCleared() method of the ViewModel. Example:- Cancellation of a Coroutine. Working of ViewModel: There are three terms  related to ViewModel to un...

Architectural patterns in Software Engineering

Image
Hello friends hi. This post is regarding all about Architectural Patterns in Software  Engineering. Architectural Patterns isn't about any specific domain like Android or Web, It is common to all software development environment. Architectural Pattern is very important for building a robust, maintainable and testable software because its main pillar is the Separation of Concern that separate the business layer with the UI layer and provide a handy testing environment. So an architectural pattern is a concept that solves and delineates some essential cohesive elements of a software architecture. Countless different architectures may implement the same pattern and share the related characteristics. Patterns are often defined as "strictly described and commonly available" In Android application development there are mainly three architectural patterns which are as... 1)- MVC (Model-View-Controller) 2)- MVP (Model-View-Presenter) 3)- MVVM (Model-View-ViewModel) So let discuss...

All about Fragment in Android

Image
Hello friends hi. This post is regarding all about Fragment in Android. Fragment is also one of the most important and useful topic in Android. So in this post we will learn the following points about Fragment... 1)- What is Fragment? 2)- What is the lifecycle of Fragment? 3)- How to implement Fragment? 4)- Difference between Activity and Fragment? These points are also very important for any interview..... So let's get start.... 1)- So the first point is what is Fragment? The answer is quite simple, A Fragment is a part of an Activity. It is also called as the sub-activity with their own lifecycle. There can be more than one Fragment in an Activity and the fragment lifecycle is affected by the activity lifecycle. 2)- What is the lifecycle of Fragment? Fragment lifecycle can be demonstrate using the following picture.... 3)- How to implement Fragment? *** Basic code in XML: <fragment android:id = "@+id/fragments" android:layout_width = "match_parent" andro...

Pending Intent in Android

Hello friends hi. This post is regarding all about Pending Intent in Android. Here are the main points about Pending Intent... 1)- What is Pending Intent? 2)- What are Pending Intent constants? 3)- How to create Pending Intent for Broadcast Receiver? 4)-  How to create Pending Intent for Activity? 5)-  How to create Pending Intent for Service? 6)- What are the main purpose of request code parameter in Pending Intent? 7)- How to cancel a Pending Intent? 8)- What is the use case of Pending Intent in Notification? 9)- How to pass extra data with a Pending Intent? 10)- What happen if we create two Pending Intent with same request code and  activity? These above question are the most important for not only the development but also for the interview purpose... So let's get start.... 1)- What is Pending Intent? In simple words, a Pending Intent can be  defined as "A description of an Intent and the target  action perform with it." On the other hand, A pending Int...

Content Provider in Android

Image
Hello friends hi. This post is regarding all about Content Provider in Android. Content Provider is also one of the most important topic of  Android Application. So let's get start.... Basically a Content Provider manages access to a structured set of data. It encapsulate the data and  the mechanism for defining data security. It is used to share the data between different applications. Content Providers   support the  four  basic operations, normally called  CRUD - operations. What is Content URI  ( Universal Resource Identifier )? Content URI is the key concept of content provider. To query a content provider, you can specify the query string in the form of URI. URI:  content://authority/data_type/id content://  →  This is prefix of all the URI and it is mandatory part of URI. authority  →  This part should be always unique for every content provider, it specify the name of content provider. for example contacts, browser etc....