mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 01:43:14 +08:00
feat(core): android cookie manager setup (#10657)
This commit is contained in:
@ -73,6 +73,8 @@
|
||||
public error: java.lang.Exception;
|
||||
}
|
||||
|
||||
export function setCookieManager(cookieManager: java.net.CookieManager): void;
|
||||
export function initializeCookieManager(): java.net.CookieManager;
|
||||
export function MakeRequest(options: RequestOptions, callback: CompleteCallback, context: any);
|
||||
}
|
||||
}
|
||||
|
@ -297,10 +297,32 @@ public class Async {
|
||||
private static final String HEAD_METHOD = "HEAD";
|
||||
private static CookieManager cookieManager;
|
||||
|
||||
public static void setCookieManager(CookieManager manager) {
|
||||
if(manager == null) return;
|
||||
|
||||
cookieManager = manager;
|
||||
if (CookieHandler.getDefault() == null) {
|
||||
CookieHandler.setDefault(manager);
|
||||
}
|
||||
}
|
||||
|
||||
public static CookieManager initializeCookieManager() {
|
||||
if (cookieManager == null) {
|
||||
CookieHandler defaultHandler = CookieHandler.getDefault();
|
||||
if (defaultHandler instanceof CookieManager) {
|
||||
cookieManager = (CookieManager) defaultHandler;
|
||||
} else {
|
||||
cookieManager = new CookieManager();
|
||||
CookieHandler.setDefault(cookieManager);
|
||||
}
|
||||
}
|
||||
|
||||
return cookieManager;
|
||||
}
|
||||
|
||||
public static void MakeRequest(final RequestOptions options, final CompleteCallback callback, final Object context) {
|
||||
if (cookieManager == null) {
|
||||
cookieManager = new CookieManager();
|
||||
CookieHandler.setDefault(cookieManager);
|
||||
initializeCookieManager();
|
||||
}
|
||||
|
||||
final android.os.Handler mHandler = new android.os.Handler(Looper.myLooper());
|
||||
|
Reference in New Issue
Block a user