[英]Is it possible to reuse RemoteViews in an appWidget instead of creating new ones every time? and how can I store them?
[英]How to store cookies, and reuse them in another session
我正在嘗試從網頁上對用戶進行身份驗證,存儲cookie並從其他網頁上以已驗證用戶身份加載rss feed。
我將WebView與該WebViewClient一起使用,該WebViewClient在用戶進行身份驗證時加載了RSS鏈接(URL完成加載):-直到用戶登錄並按下另一個鏈接后,該鏈接才會重定向。如何在登錄后直接重定向?
class LinkWebViewClient extends WebViewClient
{
//Callback method for when the url is finished loading
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
view.loadUrl("https://something.com/todays-rssfeeds");
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
CookieSyncManager.getInstance().sync();
};
}
主要問題是當我嘗試加載第二頁時,我必須重新進行身份驗證,因為它不是同一會話。
關於如何解決這些問題的任何建議?
這些是我的Cookie設置:
/
/ use cookies to remember a logged in status
CookieSyncManager.createInstance(this);
CookieManager cookieManager = CookieManager.getInstance();
//After Login
List<Cookie> cookies = httpClient.getCookieStore().getCookies();
if (!cookies.isEmpty()) {
for (int i = 0; i < cookies.size(); i++) {
cookie = cookies.get(i);
}
}
Cookie sessionCookie = cookie;
if(sessionCookie != null)
{
String cookieString = sessionCookie.getName() +"="+sessionCookie.getValue()+"; domain="+sessionCookie.getDomain();
cookieManager.setCookie(myUrl, cookieString);
CookieSyncManager.getInstance().sync();
}
所有幫助表示贊賞! 謝謝
Cookies與域綁定,但是如果這些頁面共享身份驗證系統(我認為不太可能),則可以手動將會話標識符傳遞給第二個頁面。 如果不是,問題是該第二頁應如何授權用戶?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.