DominicM
DominicM

Reputation: 2196

Android loopj: Post data

I'm using loopj to post some data. It all works fine but I have some problems:

I just need an extremely stable way to post data. Do you recommend to use another library than loopj?

Upvotes: 1

Views: 704

Answers (2)

Sangharsh
Sangharsh

Reputation: 3019

A way to reliably transfer data:

  1. Insert request in SQLite database
  2. Make POST request
  3. Delete appropriate row onSuccess()
  4. Retry pending rows on SQLite when internet is back (android.net.conn.CONNECTIVITY_CHANGE)

From AsyncHttpClient class:

private static final int DEFAULT_MAX_CONNECTIONS = 10;
private static final int DEFAULT_SOCKET_TIMEOUT = 10 * 1000;
private static final int DEFAULT_MAX_RETRIES = 5;
private static final int DEFAULT_SOCKET_BUFFER_SIZE = 8192;

Upvotes: 1

iForests
iForests

Reputation: 6949

You can override onFailure() when it failed, and deal with the situation there.

@Override
public void onFailure(Throwable e) {
    Log.d(TAG, e.toString());
}

And yes, there is timeout in AsyncHttpClient, 10 seconds by default. You can change it by setTimeout(int).

Upvotes: 0

Related Questions