Activities are the basic components of any Android app. You may ask what exactly is an activity in android? By definition:
An activity represents a single screen with a user interface just like window or frame of Java.
By digging deeper into this definition, we find that it is what helps us draw the user interface. There can be multiple activities, but always only one "Main" or launching activity which is the one the user interacts with when the app is launched for the first time. Activities basically follow state transition patterns, which basically means it goes through a series of steps right from initialization until it is stopped. In very basic layman terms, you can consider an activity lifecycle to be metaphorically similar to a vendor.
As per a vendor's business lifecycle, say to start a business a vendor needs to create the objects of the trade, followed by actually starting to setup the objects of the trade ,then opening up his store for business, followed by ongoing transactions, followed by taking breaks in between when necessary, then returning back to business, followed by stopping for the day, then returning the following day and when the business doesn't work out selling out the store and shutting down for good.
Similarly, an activity is the vendor in this case. You need to first create the activity. This is done in the onCreate() method, where you initialize the essential components of your activity (say objects of trade). That is followed by onStart() method where these objects become visible (opening up the store where these objects are about to become visible to clients) , then you get into the flow where the activity has become visible, which is done through the onResume() method( in this case the objects that are being sold come under focus of the clients), followed by the activity running phase, where the activity is in the running state (our vendor is in business!) , followed by onPause where the activity loses focus (usually due to another activity taking over , in our case analogous to taking breaks) , followed by onStop where the activity is no longer visible( shutting down the store), but can always be restarted as and when required, in which case it goes back to onStart() method (aka opening the store), followed by onDestroy method where the activity gets destroyed( out of business!).
In this way, the entire lifetime of an activity revolves between the call to onCreate() and the onDestroy() states, whereas the visible lifetime starts between the onStart() and onStop() states.
Also, the foreground lifetime of an activity basically happens between the onResume() and onPause() states. The diagram below illustrates the activity lifecycle which we just discussed in brief detail:
The Beautiful world of Activities
8:40 PM | | 0 Comments
Welcome to the world of Android
A new beginning, a fresh start or a new challenge, whatever you would like to call it, A couple of years ago, precisely back in 2013 I decided to make the switch to Android. To learn more about this field, to explore it's features and everything that people brag about starting from the basic features which android developer's claim that Apple stole from Android.
I decided to write this blog after being dormant for years to share my knowledge about the basics, to be able to share what I learned in the simplest way possible as I have done in the past and hey of course teaching is the best form of learning. So without further delay, let's get started.
Now , you would ask me, what is Android? The definition says:
" Android is a mobile operating system developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets."
But digging deeper into the technical side, as a developer, it's much more than the mere definition listed above. Let's cover the basic diagram as below:
1:17 PM | | 0 Comments

