您好先生我是Android的新手,并希望持续cookie,直到用户点击signout.but目前我使用默认Cookiemanger几小时后删除cookie,我的应用程序变得反应迟钝所以应用程序无法进一步认证调用服务器获取数据和应用程序死亡.
我已经看到很多代码并使用cookie存储来保持cookie活着,但我失败了.我无法理解在哪里编写代码,这样每次我打电话给服务器然后cookie自动进入服务器.
这是我的代码:
public class PersistentCookieStore implements CookieStore {
/**
* The default preferences string.
*/
private final static String PREF_DEFAULT_STRING = "";
/**
* The preferences name.
*/
private final static String PREFS_NAME = PersistentCookieStore.class.getName();
/**
* The preferences session cookie key.
*/
private final static String PREF_SESSION_COOKIE = "session_cookie";
private CookieStore mStore;
private Context mContext;
/**
* @param context The application context
*/
public PersistentCookieStore(Context context) {
// prevent context leaking by getting the application context
mContext = …Run Code Online (Sandbox Code Playgroud)