Android examples for Hardware:Device Feature
Returns the default User-Agent associated with the device.
//package com.java2s; import android.content.Context; import android.os.Build; import android.text.TextUtils; import android.webkit.WebSettings; import android.webkit.WebView; public class Main { private static String sDeviceUserAgent; /**/* www .j ava2s. c om*/ * Returns the default User-Agent associated with the device. * * @param context * @return */ @SuppressWarnings("NewApi") public static String getUserAgent(Context context) { if (null == context) return ""; if (TextUtils.isEmpty(sDeviceUserAgent)) { sDeviceUserAgent = (Build.VERSION.SDK_INT >= 17) ? WebSettings .getDefaultUserAgent(context) : new WebView(context) .getSettings().getUserAgentString(); } return sDeviceUserAgent; } }