2

I've recently noticed a little half height android appear to the right hand side of the address bar in Firefox for Android.

It seems this is an indicator that a native app is available for the website that you are viewing (StackExchange being one such site!) - tapping the icon launches the app and parameters seem to be passed to load the same page in the app or to do something appropriate.

Is this part of the HTML markup to alert the browser that an app is available or does Android 'just know' from when the app was installed?

(In fact, does the icon appear when there is an app is available but it is not installed?)

Thanks,

FM

-- Update --

I uninstalled the Stack Exchange App and the icon disappeared from the Firefox address bar so it seems the icon is only displayed when the app is already installed on the device.

Fat Monk
  • 2,077
  • 1
  • 26
  • 59
  • Does this appear only for apps that you have installed? Or does it appear when visiting sites for which you do not have the corresponding app? – CommonsWare Mar 19 '14 at 14:27
  • Updated the question having tested whether ask needs to be installed on device for icon to appear in address bar. – Fat Monk Mar 20 '14 at 10:06
  • None of these answers work for me, can anyone help me on how can I implement this to my website/app? – Arda Çebi Feb 01 '18 at 18:35
  • Jerome's answer (the excepted one) is correct. When developing an android app you include intents in the manifest.xml for things that your app can handle. If you include an http intent you can also include all or part of the web address of the site that your app can handle. I managed to get this working on my BlueBadgeParking App - I'll add another comment with the code. – Fat Monk Feb 01 '18 at 18:42
  • @FatMonk Thank you, I want to mention that I understood that Jerome's answer is correct, but I don't know how can I implement that to my app. If you could add an answer or provide a code or a tutorial for me (maybe a gist) that will be so helpful to me. – Arda Çebi Feb 01 '18 at 18:48
  • Code added as requested in comment to accepted answer. – Fat Monk Feb 01 '18 at 21:14

2 Answers2

2

Firefox on Android is using a feature available natively on Android from the very first version, to launch third party applications with an Intent that can be based on URI prefix, URI scheme or MIME types. These 3rd party apps are the ones defining the Intent they support.

Firefox calls a third party application an helper app. I have found references to this expression in several bug descriptions recently, such as:

It should help you find the actual implementation, if you are interested.

  • 1
    I used the following in my BlueBadgeParking App: ` ` – Fat Monk Feb 01 '18 at 18:44
  • With the above in `manifest.xml` and the BlueBadgeParking App installed on your device the little Android icon appears in the address bar in Firefox when you visit BlueBadgeParking.com. Clicking the little Android icon then launches the BlueBadgeParking App and the URL is passed to the app in the intent so the app can display the appropriate location. – Fat Monk Feb 01 '18 at 19:04
  • @FatMonk inserted the code inside my manifest.xml file under MainAcitivty – Arda Çebi Feb 02 '18 at 12:21
0

You could probably poke around the Firefox for Android code to see how they're doing that, as I presume that's published somewhere.

My guess is that they are following this algorithm:

Step #1: Create an ACTION_VIEW Intent, with a Uri that is the URL of the page being viewed.

Step #2: Call resolveActivity() on PackageManager, supplying this Intent

Step #3: If the result of resolveActivity() is not null, add the icon to the address bar

Step #4: If the user taps on the icon, call startActivity() on the aforementioned Intent

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491