سؤال

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.

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top