1

我做了一些安卓应用。要注销,我必须向服务器发送 http 删除请求。我使用了loopj库。

所以,我做这个。

连接信息.java

public ConnectionInfo(Context ctx) {    
    this.context = ctx;    
}

public void sign_out(String Url, AsyncHttpResponseHandler handler) {
    CommonClient.setCookieStore(myApplication.getCookieStore());
    CommonClient.delete(context, Url.toString(), handler);
}

public void sign_in(HashMap<String, String> params, JsonHttpResponseHandler handler) {
    Uri.Builder requestUri = new Uri.Builder();
    requestUri.scheme(SCHEME);
    requestUri.authority(HOST);
    requestUri.path(sign_in);
    CommonClient.post(context, requestUri.toString(), params, handler);
}

CommonClient.java

public class CommonClient {
    private static final AsyncHttpClient AsyncClient = new AsyncHttpClient();

public static void post(Context mContext, String actionserver,
    RequestParams params, JsonHttpResponseHandler responseHandler) {
    AsyncClient.post(mContext, actionserver, params, responseHandler);
}

接着

一些Activity类,调用sign_in方法。

connectionInfo.sign_in(params, UserLoginJsonHandler);

并完成了一些工作,另一个Activity 类调用sign_out 方法。像这样。

connectionInfo.sign_out(url, asyncHttpResponseHandler);

但是,我登录另一个ID。在用户之前保持登录。

我想,不同的登录和注销会话或cookies什么的?

如何使用 loopj 注销?我如何解决它?

请帮我。

4

1 回答 1

0

它还有一个删除方法,AsyncHttpClient它也被重载,因此您可以选择适合您需要的方法。这是一个示例用法:

AsyncHttpClient client = new AsyncHttpClient();
AsyncClient.delete(context, url, responseHandler);
于 2014-02-16T18:06:06.010 回答