Computer Science, asked by Angelthakkar1468, 1 year ago

What is difference between broadcast receiver and intent filter?

Answers

Answered by Anonymous
0

BROADCAST RECEIVER :- Android applications have three kinds of components. In general, users don't need to know about them: they're a way for app authors to program particular behaviors into their apps. But if you're watching your apps' behavior closely such as with a task manager, or if you are automating things with an app like Tasker, it's helpful to understand how they fit together within the system.

An activity is the most familiar type of component: it's a window you can see: either full-screen or dialog-sized. An activity only runs while it's displayed on the screen. Once you leave the activity, Android will keep that app in memory ready to be started again, but the activity won't run, meaning it won't use battery or network. An app starts an activity using an intent. The intent can specify explicitly which activity to start, or it can specify an action to perform (such as opening a particular file). If more than one activity can "handle" the intent, you see the dialog asking you to choose one.

INTENT FILTER:-

If you want to know more about intent filters, first of all You should know about Intent. Let me brief about intent.

Intent:

Intents facilitates communication among components(Activity, Service and Broadcast Receiver) except Content provider.

Intents are used in the following scenarios,

To start activity

To Start Service

To Send Broadcast

Intent Type: Intent can be classified into two types ,

Implicit intent

Explicit Intent

Explicit Intent:

We'll typically use an explicit intent to start a component in your own app by specifying components(Activity, Service, Broadcast), because you know the class name of the activity or service we want to start.

e.g:

Intent i = new Intent(getApplicationContext(), ActivityOne.class); startActivity(i);

Implicit Intent:

Do not need to name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it.

eg:

Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse(url)); startActivity(intent);

Intent Filter:

We will not use intent filter in explicit intent but , When you create an implicit intent, the Android system finds the appropriate component to start by comparing the contents of the intent to the intent filters declared in the manifest file of other apps on the device. If the intent matches an intent filter, the system starts that component and delivers it the Intent object. If multiple intent filters are compatible, the system displays a dialog so the user can pick which app to use.

Similar questions