39609

Can I make an Android app that runs a web view in Chrome 39?

I'm developing an Android app that's a web page embedded inside of a web view. The web page makes use of the web audio API. It looks like Chrome 39 for Android supports that API, but no version of the basic Android browser does: http://caniuse.com/#search=web%20audio%20api

Can I detect support for Chrome 39 on an Android device? And open the web page using Chrome 39?

And ask the user to download it if he/she does not have it?

Answer1:

You can use the PackageManager to query if chrome (com.android.chrome) is installed and then retrieve the version info.

try { // Get installed Chrome package info String chromePackageName = "com.android.chrome"; PackageInfo info = getPackageManager().getPackageInfo(chromePackageName, 0); // Check the version number int versionMajor = Integer.parseInt(info.versionName.subString(0, 2)); if(versionMajor < 39) { // Chrome is installed but not updated, prompt user to update it startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + chromePackageName))); } else { // Chrome is installed and at or above version 39, launch the page startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://YourURLHere"))); } } catch (NameNotFoundException e) { // Chrome isn't installed, prompt the user to download it. startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + chromePackageName))); } catch (NumberFormatException e) { // Something funky happened since the first two chars aren't a number }

Recommend

  • How do I install a previous version of build tools in addition to the sdk?
  • How can I determine if process is 32 or 64Bit from a handle?
  • Can't find cygwin setup.exe file?
  • Unable to set a breakpoint on main while debugging a program compiled with Rust 1.10 with GDB
  • Implementing Oracle.Web.dll, Oracle.DataAccess.dll 64-bit failed on Windows Server 2008 with IIS 7.5
  • Facebook Messenger Platform - Detect user typing
  • How secure are apple APNS push notifications?
  • RegistryKey.GetSubKeyNames returns names that are not in that subkey!
  • Is there a Windows socket API call / option to “block” a range of ports à la SO_EXCLUSIVEADDRUSE
  • Portable JRE on Linux - possible?
  • Using MouseListener to select a range of cells in a grid
  • Android cannot disable cut copy paste
  • Eclipse MTJ doesn't see Java ME SDK 3.0 devices
  • blade.php method outputting it's result to the form
  • Clear fused location provider's location for testing
  • Jquery popup on mouse over of calendar control
  • How do I configure context broker accept post requests from my remote sensor?
  • saving file generated by TCPDF
  • Unable to get column index with table.getColumn method using custom table Model
  • Hardware Accelerated Image Scaling in windows using C++
  • Content-Length header not returned from Pylons response
  • Bad request using file_get_contents for PUT request in PHP
  • Python urlparse: small issue
  • Google Custom Search with transparent background
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Insert into database using onclick function
  • Can I display google adwords (AdView) in javafx on android
  • What is Eclipse's Declaration View used for?
  • Sony Xperia Z Tablet not found by adb
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Updated Ionic CLI but shows previous version (Windows)
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • How do I rollback to a specific git commit
  • How to include full .NET prerequisite for Wix Burn installer
  • LevelDB C iterator
  • Linking SubReports Without LinkChild/LinkMaster
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF