1

How can I know, from the mobile chrome browser, that a specific application is installed?

In the attached screen shot you can see that Chrome knows that Wikipedia is installed.

I wonder how did they do that?, I want to do a similar check from a WebView inside my application.

enter image description here

Ian Clelland
  • 43,011
  • 8
  • 86
  • 87
David
  • 37,109
  • 32
  • 120
  • 141
  • Is this Chrome Browser you are using on the screenshot? After triggering a few tests on Nexus 5 I thought 'Open in app' occurs only when doing a search using native Google Search Bar. On Chrome Browser searches best I get is a direct link to Play Store (no matter is the application installed or not). – harism May 10 '14 at 23:34
  • The screen shot was taken from the Google search bar, but it happens also with the chrome mobile browser – David May 11 '14 at 04:57

1 Answers1

2
PackageManager packageManager = getPackageManager();
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_META_DATA)

Returns a list of installed applications. You can also get the uninstalled applications list by using GET_UNINSTALLED_PACKAGES flag.

You can create a class that has a method which checks if the given application is installed. Then you can register that class to the webView using addJavascriptInterface method. And in the page you loaded in to the webview, you can call that method to check if the given application is available in the phone. Check this answer for further info about addJavascriptInterface https://stackoverflow.com/a/9982135/3133545

Community
  • 1
  • 1
Onur
  • 5,617
  • 3
  • 26
  • 35
  • I edit my question to be more clear, I want to do a similar check from a WebView inside my application. Is it possible? – David May 10 '14 at 23:24