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:
- 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?
Basically, you get a list of applications that handles the
Intent
that you send from your application.For example, if you create this intent
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.
According to this:
and this:
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 haveChrome
.The way this is done in code is shown here.
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.