接受WebView中的所有cookie |安卓
我一直在试图为我的问题找到一个解决方案。由于某种原因,我的代码不会在WebView中自动接受cookie。 也许一个比我更好的理解的人可以理解这个问题:
public class HomeActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
setTitle("Title");
WebView wb = (WebView) findViewById(R.id.Login);
if (android.os.Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(wb, true);
}else {
CookieManager.getInstance().setAcceptCookie(true);
}
wb.setWebViewClient(new WebViewClient());
wb.loadUrl("PRIVATELINK");
}
}
I have been trying to find a solution so long to my problem. for some reason, my code doesn't automatically accepts cookies in the webview.
Maybe someone who understands better than me could understand the problem:
public class HomeActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
setTitle("Title");
WebView wb = (WebView) findViewById(R.id.Login);
if (android.os.Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(wb, true);
}else {
CookieManager.getInstance().setAcceptCookie(true);
}
wb.setWebViewClient(new WebViewClient());
wb.loadUrl("PRIVATELINK");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论