Java tutorial
//package com.java2s; import java.lang.reflect.Constructor; import android.content.Context; import android.webkit.WebSettings; import android.webkit.WebView; public class Main { public static String getDefaultUserAgentString(Context context) { // String userAgent = System.getProperty("http.agent"); try { Constructor<WebSettings> constructor = WebSettings.class.getDeclaredConstructor(Context.class, WebView.class); constructor.setAccessible(true); try { WebSettings settings = constructor.newInstance(context, null); return settings.getUserAgentString(); } finally { constructor.setAccessible(false); } } catch (Exception e) { return new WebView(context).getSettings().getUserAgentString(); } } }