1

I make some android app. To log out, I must send http delete request to server. I used loopj liberary.

So, I make like this.

ConnectionInfo.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);
}

and then

Some Activity class, call sign_in method.

connectionInfo.sign_in(params, UserLoginJsonHandler);

and Finished some work, the other Activity class call sign_out method. Like this.

connectionInfo.sign_out(url, asyncHttpResponseHandler);

But, I login another ID. Keeping login before user.

I think, different login and logout session or cookies something?

How Can I logout using loopj? How do I Fix it?

Please help me.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user3316557
  • 171
  • 1
  • 6
  • Oh sorry. I am already make delete method. But not work. In fact, the method work very well. server return 204 to me. But keep alive login status. – user3316557 Feb 16 '14 at 23:40

1 Answers1

0

There is a delete method on the AsyncHttpClient it is also overloaded so you can choose the one that fits your need. here is a sample usage :

AsyncHttpClient client = new AsyncHttpClient();
AsyncClient.delete(context, url, responseHandler);
Hannoun Yassir
  • 20,583
  • 23
  • 77
  • 112
  • Oh sorry. I am already make delete method. But not work. In fact, the method work very well. server return 204 to me. But keep alive login status. – user3316557 Feb 16 '14 at 23:40