gpt4 book ai didi

android - 设置/更改更改 Android 中的 WebView 用户代理

转载 作者:可可西里 更新时间:2023-11-01 11:42:02 26 4
gpt4 key购买 nike

我有一个网站应该只在我的应用程序中使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com