Explicit intentions, implicit intentions and broadcasts

I'm trying to better understand the topic of intent.

The explicit intent is configured with the component name. In every example I saw, it was used to start or stop a component. Is this the sole purpose of sheer intention?

In implicit intent, there is no target component. Implicit intentions can also start / stop a component, but they can also be obtained by BroadcastReceivers. Is there any other way to get an implicit intent?

When the OS sends an intent with an action set to Action.MAIN, what is the explicit intent, right?

Thanks.

+6
source share
4 answers

From the documentation for Android:

Explicit intentions define the component to run by name (fully qualified class name). Typically, you will use the explicit intention to run the component in your own application, because you know the class name about the activity or service that you want to start. For example, start a new one in response to a user action or start a service to download a file in the background.

Implicit intentions do not name a specific component, but instead declare a general action to execute that allows a component from another application to handle it. For example, if you want to show the user a location on a map, you can use the implicit intent to request that another capable application display the specified location on the map.

Explicit intentions, as you said, are used to start activity in your application - or to move from one “screen” to another. An explicit intention would be something like Intent intent = new Intent(currentContext, ActivityB.class); These types of intentions are used when you are in your application, and you clearly know which component you want to run, depending on how the user interacts with your activity.

Implicit Intents does not directly indicate the Android components that should be called, but simply indicate the general action that needs to be performed. They are usually used when you want some external application to do something for you. An example of an implicit intent used to send email using an external application would be:

 Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL , new String[]{" someemail@gmail.com "}); i.putExtra(Intent.EXTRA_SUBJECT, "subject"); i.putExtra(Intent.EXTRA_TEXT , "body"); 

This intention will request applications installed on the device that can handle sending emails, but there may be quite a few applications that can do this - for example, if we have a gmail application, a hotmail application, etc., basically you just specify the general action and ask the system "who can handle this", and the system will process the rest. These types of intentions are used by application developers, so they don’t need to “reinvent the wheel” if the device already has something that can do what the developer wants to do.

Here are some links that could help you do better:

http://developer.android.com/guide/components/intents-filters.html

http://www.vogella.com/articles/AndroidIntent/article.html

+6
source

Is this the sole purpose of sheer intention?

An Intent commonly used for:

  • start action
  • start or stop service
  • send broadcast

For any of these, an explicit Intent can be used.

Implicit intentions can also start / stop a component, but they can also be received by BroadcastReceivers.

Whether Intent implicit or explicit does not depend on what role Intent used for.

Is there any other way to get an implicit intent?

Implicit Intent performs the roles listed above. Usually you do not see that it is used to start and stop the service.

When the OS sends an intent with an action set to Action.MAIN, what is the explicit intent, right?

Not necessary. If by "OS" you mean "home screen", and "sends an intention with the action set in Action.MAIN," you mean "starts an action based on the user clicking on the icon in the launch bar", then there is an explicit Intent to determine the specific activity to run. An explicit Intent can have an action string, so it does not ACTION_MAIN make an explicit Intent .

+3
source

Intent is an object that is used to communicate between any android component (Activity, Services, BroadcastReceiver, ContentProvider) and the operating system.

Intent Class provides various constructors depending on what we intend to do.

In case, Intent sends an ActivityManager request, the launch of which begins. ActivityManager is part of the OS.

Now the question is, why do we require an ActivityManager, which is located outside our application, for communication between two actions inside the application. Here comes the concept of implicit and explicit intent.

Explicit intention. For communication between components (Activity) in one application, we use an explicit intent. For instance. Send the current date from one activity to another.

Implicit intention: to communicate between the actions of different applications. For instance. One application requesting photos from the gallery application.

Implicit Intent ActivityManager simplifies the process.

+1
source

As its name suggests, Intent → It is “intention” to take action.

This is a way to send a message to perform an action that may be listened to by another application or OS.

In the clear intention, you know what kind of work to do which person or class.

In implicit intention, you simply ask for work ... all applications that can perform actions, such as sharing a message, will be displayed in the list, and you can do your work with any of them.

0
source

All Articles