Pregunta

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

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top