A question can be opened in a browser from the app by using the eponymous item on the "More" menu:


I'm a big fan of this functionality, but notice that I have two browsers installed and the menu offers no option to select a default app (no "This time"/"Every time" choice). I'm lazy and don't like having to choose one every time. Other redirections to a browser, like external links or Careers ads, work normally and use my selected default for hyperlinks.

What Android Intent does this specifically use? I'm trying to manually set the default action and can't figure it out.

  • You mean you have the question opened in one browser without the right to choose the browser? – nicael Jun 28 '15 at 11:37
  • No. It doesn't allow me to set a default so I have to choose a browser every time. The fault is with my phone's ROM, not the SE app. If I know the intent, I can go set up the default manually. – Esoteric Screen Name Jun 28 '15 at 11:41
  • This as Android/your phone specific not Stack. If you can make the question more clear perhaps Stack devs might be able to help their side, but it's more likely your phone config or settings. I'm not 100% sure what you're asking exactly, but on my phone such things as in your image I can choose "just this time" or "every time". I might be barking up the wrong tree, but again, make your question more clear and we can help :) – James Jun 28 '15 at 16:33
  • This seems like a fair question to me. It's very specifically about a technique used in the Android app. I know I get put out when an app does something in a non-standard way and bypasses my defaults. @Esoteric: I don't know that you'll get an answer to this. Perhaps instead you should file this as a bug report. – ale Jun 28 '15 at 19:53
  • @James the setting is specific to my phone, yes. I'm asking for the technical details of what that setting is, so I can change it. The problem is that I don't get the just this time/every time choice. This implies that I've already set the default or the app is doing something unusual (turns out it's both in this case). – Esoteric Screen Name Jul 6 '15 at 2:22

The problem is that if we used Android's default "choose what to do" dialog, then

  • the list you're given will include the Stack Exchange app itself, which would be highly surprising, and
  • even worse, if that Stack Exchange app is set as your default handler for Stack Exchange URLs, then Android would just open it with the app again without asking, which is exactly what you do not want to do.

There is no way to tell Android "use the system's default handling, but exclude this very app". In my experience, many app developers don't care because they don't want you to leave their app anyway. Unfortunately that means we have to work around it.

To answer your precise question, we first create an ACTION_VIEW intent with the question's URL, and query the system what possible activities are available on the system to handle this intent (this will usually be the Stack Exchange app and all browsers you have installed). We remove the Stack Exchange app from that list. If that only leaves a single activity (i.e. you have only one browser installed), then we launch the intent with that activity. If there is more than one left, then we launch an ACTION_CHOOSER intent that lets you choose from them.

From the docs:

The user does not have the option to make one of the matching activities a preferred activity, and all possible activities will always be shown even if one of them is currently marked as the preferred activity.

  • 1
    Thanks for the explanation, which makes sense. Sadly this seems like an edge case that Android's sdk just doesn't handle. I suppose that an automated link shortener service could work around this, but that sounds far too fragile and annoying to set up and maintain. – Esoteric Screen Name Jul 6 '15 at 2:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .