What Is An Intent In Android | Explicit And Implicit Intent

In this post I will explain you what is an intent and the importance of it but before I start explaining you what is an intent. Let me first explain you the concept of an activity. Now many of you may know what does an activity but for understanding intent. It is important to understand the activity first.


Suppose you create a simple hello world application which consists of a single page and if you show this application to a non programmer then for him this is an application which consists of a single page but as Android developers instead of calling this a page we call this an activity. So according to me this is an Android app which consists of a single activity made up of two main files main a trigger on Java and activity main dot XML so if you have an application which consists of three pages then in technical terms your application consists of three activities. If you have three activities inside your application then you need some component to communicate between these activities or you need some component to jump from one activity to another activity. So to communicate between one activity to another activity we use a component called as intent.

So guys after understanding what is an activity. Let's talk about intent so intent is a messaging object you can use to request an action from an another app component. Intent facilitates communication between components.

Intents are of two types explicit intent and implicit content.

So first let's look at what is an explicit intent. An intent is called as explicit intent when you want to communicate between two activities inside the same application or if you want to jump from one activity to another activity inside the same application and intent is called as implicit intent when you want to communicate between two activities but from different application. For example suppose you have two applications inside your smartphone one is an email application and second is a web browsing application. Both the applications have the individual activities as you can see over here. If you click on the URL link inside this email app then this link will not open inside of the browser as it is and you are a link if you have two web browsing applications inside your smartphone then we can use intent for calling a chooser component meaning it will ask you a question you want to open this URL using which web browser if you have two different web browsers.

So we use explicit intents if we want to communicate between two activities inside the same application and we use implicit intent when we want to communicate between two activities inside different application. So intents are basically used to start an activity. Intents are also used to start the service. Intents are also used to pass a data from one activity to another activity inside the same application in this case as you can see if the user types the username and password inside the edit text then on the press of a button this data will be stored and passed to the next activity and displayed over there using intents. Intents are also used for broadcasting a message if suppose your phone has a low battery then your Android operating system will pass a message to all the application saying that the battery is low and the other application will see this message via the broadcast receiver and this communication between the OS and the application is carried out by intents.

So guys I hope from this post you would have got a clearer idea of what is an intent. What are their types and where are they used.

In next post we will see examples of intents in Android Studio.

Comments

Popular posts from this blog

Why You Should Learn To Code - Is a Software Developer Career Worth It?

DGVCL Recruitment for 206 Vidyut Sahayak (Junior Assistant) & Vidyut Sahayak (Junior Engineer) Posts 2018

What Can You Do With Python – Computer Programming