在webview-client中保存凭据

时间:2014-07-24 08:36:32

标签: android api authentication oauth-2.0 android-webview

我的应用程序中有一个webview:

    webview = (WebView) findViewById(R.id.webview);
    webview.setWebChromeClient(new WebChromeClient());
    webview.getSettings().setLoadWithOverviewMode(true);
    webview.getSettings().setUseWideViewPort(true);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.addJavascriptInterface(new JavaScriptInstance(this.getApplicationContext()), "HTML");

通过这个webview,我在google或facebook上通过我们自己编写的api加载了一个身份验证(oauth2)页面。 加载页面或进行身份验证没有问题,但我们希望保存凭据。

我们想要的是,如果您想再次“验证”,那么您不必输入凭据,但是webview应该保存并自动登录。

这是一张图片,在哪里“存储”凭据:http://i.stack.imgur.com/1Kkhm.png。 在这个页面上,我希望webview logIn自动使用在用户登录之前保存的凭据或类似的保存凭证。

我知道有一些功能可以使用,但我不知道如何处理它:/ 拜托,不要为我/我们的问题写一个替代方案,我们需要一个解决方案来确切地说明我所写的问题。

编辑:

仅在此webview中保存凭据/登录。 如果我想以用户

删除它,我该如何删除它们

EDIT2:

我认为

    CookieSyncManager.createInstance(this);
    CookieSyncManager.getInstance().startSync();
    CookieManager.getInstance();

应该这样做,对吧?

EDIT3: 我可以在API 14 + 15中使用这些功能(特别是JavaScriptInterface)吗?我的意思是,我已经读过,您不能将此用于此API级别,但我不知道在哪里:/

0 个答案:

没有答案