Enable Safe Browsing in WebView

This is the third post in my Android snippet series, where I go through small code snippets and tips on how to enhance your Android development. Be sure to checkout the other snippets too!

During the years Google has invested a lot of resources to the Chrome browser on Android. New features have been added, bugs have been fixed and security issues closed.

Since Android 5.0 the WebView component app developers rely on has been based on the Chrome browser and developers have been able to benefit from the updates and new features available on the standalone browser.

On the security side one of the most visible features is Safe Browsing which informs users about a potentially harmful web pages before they’re opened. Due to the nature of the web this is a really important feature and luckily it’s now available in WebView component also.

To enable the Safe Browsing feature for all WebViews in your app, you need to add a meta-data tag to the AndroidManifest like this:

<manifest>
     <meta-data android:name="android.webkit.WebView.EnableSafeBrowsing"
                android:value="true" />
      . . .
     <application> . . . </application>
</manifest>

More info about other security features is available in the Android Developers blog

Comments

comments powered by Disqus