【发布时间】:2017-06-16 19:53:52
【问题描述】:
我正在使用 facebook 登录对我的应用程序进行身份验证。每次我打开我的应用程序时,都会启动一个 webview 并要求提供 facebook 凭据以登录应用程序。
只有在用户第一次需要提供 facebook 凭据时,webview 才会存储 cookie/credencials。我尝试以编程方式删除凭据,但没有成功。
有人尝试过 API24 或 API25 吗?
【问题讨论】:
我正在使用 facebook 登录对我的应用程序进行身份验证。每次我打开我的应用程序时,都会启动一个 webview 并要求提供 facebook 凭据以登录应用程序。
只有在用户第一次需要提供 facebook 凭据时,webview 才会存储 cookie/credencials。我尝试以编程方式删除凭据,但没有成功。
有人尝试过 API24 或 API25 吗?
【问题讨论】:
试试这个!!
mWebView.clearHistory();
mWebView.clearFormData();
mWebView.clearCache(true);
android.webkit.CookieManager.getInstance().removeAllCookie();
更新 -
这里是 webview 的所有功能,如果有人遇到关于 webview 的任何其他问题,他们可以从这里找到解决方案
webView = (WebView) findViewById(R.id.web);
myLocationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setGeolocationEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCachePath( getApplicationContext().getCacheDir().getAbsolutePath() );
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setAllowFileAccess( true );
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setCacheMode( WebSettings.LOAD_DEFAULT ); // load online by default
url = "https://www.google.co.in/maps/@";
if ( !isNetworkAvailable() ) { // loading offline
webView.getSettings().setCacheMode( WebSettings.LOAD_CACHE_ELSE_NETWORK );
}
webView.loadUrl(url.toString());;
webView.setWebChromeClient(new WebChromeClient() {
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
// callback.invoke(String origin, boolean allow, boolean remember);
callback.invoke(origin, true, false);
}
});
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// For Progress/Loading bar
}});
【讨论】: