In this blog, we will discuss the Core Building blocks of Android. These building blocks are simply a piece of code that has a distinct life cycle.
Fundamental building blocks of Android are Activity, Intent, Views, Services, Content Providers, Fragments, and AndroidManifest.xml.
Let’s discuss a little bit more about these fundamental components of Android.
An activity is a single screen user interface. This the entry point of the users. Activity is the subclass of the ContextThemeWrapper class. An Activity starting with onCreate() callback method. An Activity has seven callback methods; those are used in different conditions.
Callback methods are:
- onCreate(): it called when the activity is created.
- onStart(): it called when the activity becomes visible of the users.
- onResume(): it called when users interacting with the application.
- onPause(): it called when the current activity is being paused and another activity is being resumed.
- onStop(): it called when the activity is no longer visible for the users.
- onDestroyed(): it called when activity is destroyed by the system.
- onRestart(): it called when activity is a restart after stopping it.
And we should declare our activity inside the AndroidManifest.xml file or else it going to show run time error.
The declaration will be like:
It is used to invoke components, like
- Start a new service
- Display an another activity
- Display a webpage
- Display a message etc. Example:
Intent intent=new Intent(Intent.ACTION_VIEW);
The intent has two types:
- Explicit Intent: Explicit Intent is used only for the internal purpose like to start another activity or send data between two activities. To start a new activity we have to create an Intent and set the source and destination activities. Example:
- Implicit Intent: Implicit Intent is used to connect with the outer side of the application, like to make a call, sending mail, phone, see any web sites, etc. In implicit Intent we pass the action using setAction() function. Example:
for more visit GBAndroidBlogs