2

I'm using retrofit to send data to my php webservice, which stores it on a mysql database. It works just fine most of the time, but when I use it to send pictures (as Blobs) with a post, retrofit freezes the UI thread waiting for the onResponse. After 30-40 secs the response arrives and the UI unfreezes, but it's horrible in terms of user experience. This doesn't happen when i'm doing this call without an image file. I think it has to do with the size of the files, even if I already compressed them.

Do you know how to avoid this freezing? Should I give my retrofit call to a Service ? Is there another solution ?

FYI here is the code of the call :

 Call<String> call = retrofitInterface.insertorUpdatePteChambre(postPteChambre);
    call.enqueue(new Callback<String>() {
        @Override
        public void onResponse(Call<String> call, Response<String> response) {
            if (response.isSuccessful()) {
                String resp = response.body();

            } else {
                Toast.makeText(ctx, "response not successful", Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void onFailure(Call<String> call, Throwable t) {
            Toast.makeText(ctx, R.string.error_insert, Toast.LENGTH_LONG).show();
        }
    });
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Waylan
  • 91
  • 1
  • 2
  • 9

0 Answers0