Android: Choose the application with which to open a link
Asked Answered
S

3

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?

Swartz answered 16/2, 2015 at 11:43 Comment(2)
Is this actually a programming question?Crossley
The author is asking about how the Android framework handles different Intents. Maybe a bit broad, but I would say yes. @CrossleyFloristic
M
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.

Mckinleymckinney answered 16/2, 2015 at 11:57 Comment(2)
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?Swartz
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 ?Mckinleymckinney
F
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.

Floristic answered 16/2, 2015 at 11:45 Comment(0)
K
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.

Kansu answered 16/2, 2015 at 12:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.