Android-在多个WebViews / Windows上共享本地存储

时间:2013-08-27 13:46:19

标签: android jquery-mobile android-webview local-storage

我正在开发一个应该连接到Web服务器的移动应用程序。该应用程序使用jQM编写,只需在android Web视图中导入。我试图使用jStorage插件解决这个问题,但似乎不可能在不同的页面之间共享本地存储。所以我尝试实施this,但它不起作用并继续发送null

以下是我的代码示例: 使用Javascript:

function getToken(authCode) {
    var jsonUrl = mainUrl + "/auth/authorizeToken?grant_type=authorization_code&client_id=bc89fb879a64eb8e422b94d5c39&client_secret=b5c2974b78f7f3f7aee2bed182&redirect_uri=redirection&code="+authCode;
    $.ajax({
        url: jsonUrl,
        type: "GET",
        dataType: "jsonp",
        success: function(data) {
            localStorage.setItem( "access_token", data.access_token);
            localStorage.setItem( "refresh_token", data.refresh_token);
            localStorage.setItem( "logged", "true");
        }
    });
}

function valTokens() {
    access_token = localStorage.getItem("access_token");
    refresh_token = localStorage.getItem("refresh_token");
}

之后,将值设置为null。 .java文件与给定链接中的示例相同。

0 个答案:

没有答案