How to get the Android version number?

1

I would like to know how to get the version number of Android in which my application that uses WebView is running, to put in the UserAgent, as in the code below:

 mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; App Mobile Android X.X.X; App v1.0)(KHTML, like Gecko)");

X.X.X would be the Android version.

    
asked by anonymous 07.11.2016 / 05:35

1 answer

3

You can use the Build.VERSION.RELEASE constant.

An example usage for your case would be:

mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; App Mobile Android " + Build.VERSION.RELEASE + "; App v1.0)(KHTML, like Gecko)");
    
07.11.2016 / 06:22