File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
types-android/src/lib/android
ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 7373 public error : java . lang . Exception ;
7474 }
7575
76+ export function setCookieManager ( cookieManager : java . net . CookieManager ) : void ;
77+ export function initializeCookieManager ( ) : java . net . CookieManager ;
7678 export function MakeRequest ( options : RequestOptions , callback : CompleteCallback , context : any ) ;
7779 }
7880 }
Original file line number Diff line number Diff line change @@ -297,10 +297,32 @@ public static class Http {
297297 private static final String HEAD_METHOD = "HEAD" ;
298298 private static CookieManager cookieManager ;
299299
300+ public static void setCookieManager (CookieManager manager ) {
301+ if (manager == null ) return ;
302+
303+ cookieManager = manager ;
304+ if (CookieHandler .getDefault () == null ) {
305+ CookieHandler .setDefault (manager );
306+ }
307+ }
308+
309+ public static CookieManager initializeCookieManager () {
310+ if (cookieManager == null ) {
311+ CookieHandler defaultHandler = CookieHandler .getDefault ();
312+ if (defaultHandler instanceof CookieManager ) {
313+ cookieManager = (CookieManager ) defaultHandler ;
314+ } else {
315+ cookieManager = new CookieManager ();
316+ CookieHandler .setDefault (cookieManager );
317+ }
318+ }
319+
320+ return cookieManager ;
321+ }
322+
300323 public static void MakeRequest (final RequestOptions options , final CompleteCallback callback , final Object context ) {
301324 if (cookieManager == null ) {
302- cookieManager = new CookieManager ();
303- CookieHandler .setDefault (cookieManager );
325+ initializeCookieManager ();
304326 }
305327
306328 final android .os .Handler mHandler = new android .os .Handler (Looper .myLooper ());
You can’t perform that action at this time.
0 commit comments