So, when I enter the server-side application, it gives me a cookie that allows me to say “Hey, this is me again” for future requests. I used to do this using the default HttpClient classes for Android, and it worked fine. But I was told that Retrofit is much faster and saves you JSON parsing by implementing GSON, so I decided to give it a try.
I built my client and I can make requests, however my client does not remember the session key, and therefore I can not do anything. Does anyone know how to report the “accept and user cookies for future requests” update? I'm lost here! will make any offer :)
public class ApiClient{ private static final String API_URL = "http://192.168.1.25:8080"; private static RestAppApiInterface sRestAppService; public static RestAppApiInterface getRestAppApiClient() { if (sRestAppService == null) { CookieManager cookieManager = new CookieManager(); cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cookieManager); RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(API_URL) .build(); sRestAppService = restAdapter.create(RestAppApiInterface.class); } return sRestAppService; } }
json android cookies retrofit session
feresr
source share