Android/webview/useragent
提供: 初心者エンジニアの簡易メモ
サンプル
WebView webView = new WebView(getApplicationContext()); final WebSettings settings = webView.getSettings(); Log.i("tag", settings.getUserAgentString()); // 読み込み settings.setUserAgentString("Mozilla/5.0 (Linux; Android 8.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.121 Mobile Safari/537.36"); // 書き込み
ua参考コード
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { userAgent = WebSettings.getDefaultUserAgent(context); } else if (Looper.myLooper() == Looper.getMainLooper()) { userAgent = new WebView(context).getSettings().getUserAgentString(); }