如何在Android WebView中保存Google登录会话?

huangapple go评论50阅读模式
英文:

how to save google login session android webView?

问题

webView = findViewById(R.id.webView);
String url = "https://www.youtube.com/watch?v=" + vidInfo[vidNum][2];
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setAppCachePath(getCacheDir().getPath());
webSettings.setAppCacheEnabled(true);
webSettings.setMediaPlaybackRequiresUserGesture(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(url);

英文:

i have an android app with a webView to open some youtube links but i have a problem that every time the app close and reopen i need to login again i read some questions here but didn't got an answer this is my code.

webView = findViewById(R.id.webView);
    String url = "https://www.youtube.com/watch?v="+vidInfo[vidNum][2];
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setAppCachePath(getCacheDir().getPath());
    webSettings.setAppCacheEnabled(true);
    webSettings.setMediaPlaybackRequiresUserGesture(true);
    webView.setWebViewClient(new WebViewClient());
    webView.loadUrl(url);

答案1

得分: 1

你的会话数据被保存在Cookies中。因此,在不同会话之间需要使它们持久化。

查看这个回答

英文:

your session data is saved in cookies. you therefore need to make them persistent between sessions
checkout this answer

huangapple
  • 本文由 发表于 2020年5月2日 16:59:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/61556824.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定