1

In Android applications, often the choice of selecting an app to open a link or do some other action is left to the user, i.e. the framework lets the user choose the app to do something.

For example, say you have a link to a tweet, and you are allowed to choose between:

  • Twitter
  • Chrome
  • Web Browser

What is the reason that the user is allowed to choose the application with which to open a link rather than with native application?

Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
user1826240
  • 95
  • 10

3 Answers3

3

According to this:

An implicit intent specifies an action that can invoke any app on the device able to perform the action. Using an implicit intent is useful when your app cannot perform the action, but other apps probably can and you'd like the user to pick which app to use.

and this:

The real power of intents lies in the concept of implicit intents. An implicit intent simply describes the type of action to perform (and, optionally, the data upon which you’d like to perform the action) and allows the system to find a component on the device that can perform the action and start it. If there are multiple components that can perform the action described by the intent, then the user selects which one to use.

The idea is that in Android, a developer can let his app use another app on the device to perform some task, instead of having to recreate the same functionality within their own app. Often, there is more than one app that can perform the same task, and so Android allows the user to select which app they want to use for that task.

Basically, the framework attempts to provide the most general way of getting a task done: if the official Twitter app is not present, then you always have Chrome.

The way this is done in code is shown here.

Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
  • First of all, thanks to everybody for the anwsers. My question is more focused on the fact let you choose which application to open this link, rather than open it directly with the official application (if installed). Is there any special reason? – user1826240 Feb 16 '15 at 15:19
  • As I said above, the framework uses the most general way of getting a task done: if the official `Twitter` app is not present, then you always have `Chrome`. Just consider: if the user had not installed the `Twitter` app on their device, then in the absence of other options they would have no way to post a Tweet. Therefore, the framework always tries to give MULTIPLE ways to complete a task. Does this make sense ? – Yash Sampat Feb 16 '15 at 17:08
1

Basically, you get a list of applications that handles the Intent that you send from your application.

For example, if you create this intent

Uri number = Uri.parse("tel:5551234");
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);

Any application that can handle Intent.ACTION_DIAL will appear on your chooser list. In your case, when you handle links, Twitter, Chrome and Web Broswer are all applications that can handle these Intents, hence they appear in the chooser list.

You can read more about this here.

Marcus
  • 6,697
  • 11
  • 46
  • 89
1

Google introduced implicit intents, but these intents are ambiguous, and Google decided to let the human solve the ambiguity.

In some cases the robot just cannot make the right choice. For example, how can robot decide what app must open a link with from the list: Opera, Chrome, Web browser?

It may look like apps like twitter and google translate are better suited for specific links, but in practice apps are glitchy (apps update automatically so that bugs may creep in, while the servers update implying that the apps update, so that the bugs may creep in even on devices with automatic updates turned off), and sometimes the user may wish to open a link with a browser rather than with the dedicated app.

18446744073709551615
  • 16,368
  • 4
  • 94
  • 127