我有一个网站应该只在我的应用程序中使用 WebView,否则我的网站会将用户重定向到他可以下载我的应用程序的页面。
那么,如何在 WebView 中更改此 UA?
此外,由此可能引起的问题是什么?
最佳答案
您可以使用 setUserAgent
来自 android.webkit.WebSettings
,简单示例:
WebView myWebView = (WebView) findViewById(R.id.myWebView);
WebSettings myWebSettings = myWebView.getSettings();
myWebSettings.setUserAgentString("Foo/Bar"); # Set your custom user-agent
Also, what are the possible issues which can arise from this?
取决于你做了什么,userAgent
并不“完美”,而是为此目的而创建的,识别浏览器。
关于android - 设置/更改更改 Android 中的 WebView 用户代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35866310/