마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

웹뷰 자동로그인 문제입니다..

0 추천

 

안녕하세요,

 

웹뷰 자동로그인 부분때문에 고민입니다.

여러분들은 어떻게 자동로그인처리를 하시는지 궁금합니다..ㅠㅠ

@Override
protected void onResume() {
super.onResume();
CookieSyncManager.getInstance().startSync();

}

@Override
protected void onPause() {
super.onPause();
CookieSyncManager.getInstance().stopSync();

}

 

요걸로 해도,, 자동로그인이 풀려버리네요,ㅠㅠ

kth8295 (290 포인트) 님이 2019년 4월 16일 질문

1개의 답변

0 추천

CookieSyncManager.getInstance().sync(); 로 캐쉬값을  sync 하셨나요? 

 

https://www.fun25.co.kr/blog/android-webview-cookie-sync/?category=003

익명사용자 님이 2019년 4월 17일 답변
CookieSyncManager는 dprecated 됐는데요.

 * @deprecated The WebView now automatically syncs cookies as necessary.
 *             You no longer need to create or use the CookieSyncManager.
 *             To manually force a sync you can use the CookieManager
 *             method {@link CookieManager#flush} which is a synchronous
 *             replacement for {@link #sync}.
 */
@Deprecated
public final class CookieSyncManager extends WebSyncManager {
}

수동으로 강제 sync를 하려면 CookieManager.getInstance().flush를 쓰라고 하네요.

/**
     * Ensures all cookies currently accessible through the getCookie API are
     * written to persistent storage.
     * This call will block the caller until it is done and may perform I/O.
     */
    public abstract void flush();

근데 CookieManager.flush가 blocking call입니다.  Background thread 에서 호출하셔야 해요..
...