0

I am using an intent service to compress few video files using FFMPEG library and after compression, store these files on a server using FTP. So, I started a thread to wait for FFPEG execute() method until it finished successfully.

Then, I store these files on the server using FTP. The work is done correctly, but in the end it returns illegalStateException:

MessageQueue: Handler (android.view.ViewRootImpl$ViewRootHandler) {8895619} sending message to a Handler on a dead thread

If I have 10 files, this exception is returned 10 times. What could be the reason for this exception and how can I avoid it.

Here is the handler i am using:

            fFmpeg.execute(command, new ExecuteBinaryResponseHandler() {
            @Override
            public void onFailure(String s) {
                System.out.println(idx + "----------Failure: \n" + s.toString());
            }

            @Override
            public void onSuccess(String s) {
                System.out.println(idx+ "----------Success: \n" + s.toString());
            }

            @Override
            public void onProgress(String s) {
            }

            @Override
            public void onStart() {
                System.out.println(idx+ " started");
            }

            @Override
            public void onFinish() {
                totalProcessedFileCount++;
                System.out.println(idx + "*****************Finished "+ totalProcessedFileCount);
            }
        });
KMSG Tech
  • 1
  • 1
  • the problem is related to the handler you are using, it describes that there is a message sent to the handler, but the thread in which the handler is created is dead. If you post the handler you are using and the usage of it I could provide more hints – petrumo Jan 19 '17 at 15:21
  • @petrumo I have added handler code in question. – KMSG Tech Jan 20 '17 at 05:56

1 Answers1

0

You can try by running the handler on a separate thread.

HandlerThread handlerThread = new HandlerThread();
handlerThread.start();

and attach the handler to the new thread

new ExecuteBinaryResponseHandler(mHandlerThread.getLooper());
petrumo
  • 1,116
  • 9
  • 18