Handler on android not receiving the message

LittleFunny

I have a code running inside the Thread. I tried to use the handler to do receive the message from the thread so i can update the UI. Unfortunately, the message didn't get send to the handler.

This is my code snippet inside the run method of the Thread

                    ChromaticLayout chromatic =  new ChromaticLayout(mPartition, mDeviceWidth, mDeviceHeight, mData);
                    chromatic.execute(new ChromaticLayout.LayoutCallback() {

                        @Override
                        public synchronized void retrieveResult(Object[][] data) {
                            // TODO Auto-generated method stub
                            mPhotoData.clear();
                            Log.w("CALLBACK", "start");

                            for (int i=0; i<data.length; i++) 
                            {
                                PhotoFrameData[] row = new PhotoFrameData[data[i].length];

                                for (int j=0; j<data[i].length; j++) {
                                    if (j==0)
                                    Log.w("CALLBACK", "Width = " + ((PhotoFrameData) data[i][j]).getRectangle().width() + " height = " +  ((PhotoFrameData) data[i][j]).getRectangle().height() );

                                    row[j] = (PhotoFrameData) data[i][j];
                                }
                                mPhotoData.add(row);

                            }
                            Log.w("CALLBACK", "end");

                            PhotoFrameAdapter.this.handle.post(new Runnable(){

                                @Override
                                public void run() {
                                    // TODO Auto-generated method stub
                                    PhotoFrameAdapter.this.handle.sendEmptyMessage(1);
                                } });
                            //if (!PhotoFrameAdapter.this.handle.sendEmptyMessage(1))
                            //  Log.w("CALLBACK", "Handle not working");
                        }});

                }

The is the receiving message of the handler:

protected Handler handle = new Handler() {

        public void handleMessage(Bundle message) {
            //PhotoFrameAdapter.this.notifyDataSetChanged();
            mListener.dataLoaded(this);
        }
    };

What make it not adding to the message queue and call the handleMessage? Thanks

santalu

try this:

private Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case 1:
                //do staff
                break;
            }
        };
    };

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ActiveMQ different ways for receiving message

From Dev

Threaded SocketServer not receiving second message

From Dev

java.lang.RuntimeException: Handler (android.os.Handler) sending message to a Handler on a dead thread

From Dev

Android loopj + GCMIntentService sending message to a Handler on a dead thread

From Dev

Android - Sending Message to Thread Incoming Handler

From Dev

Erlang message receiving order

From Dev

The "this" pointer and message receiving in D

From Dev

Android stop notification in status bar while receiving message

From Dev

When receiving the sms, only the message was displayed but app didnt open - Android

From Dev

Receiving "role" and/or "affiliation" with message in SleekXMPP

From Dev

Synchronizing message sending and receiving AGSXMPP

From Dev

Android Wear - receiving message from Wear without WearableListenerService?

From Dev

How to customize Qt Message Handler on Android

From Dev

Child process not receiving message

From Dev

Android handler remove send message not working

From Dev

gcm not receiving message on client side

From Dev

Receiving message in a transaction

From Dev

android - bluetooth adapter - message handler buffer limit

From Dev

Android - What is an Handler Message?

From Dev

Message handler not activating

From Dev

Android: Delay in Receiving message in FCM(onMessageReceived)

From Dev

Android EventBus - Sequence for receiving message

From Dev

No-message listener for handler

From Dev

Server not receiving message properly?

From Dev

Receiving "role" and/or "affiliation" with message in SleekXMPP

From Dev

Elixir process not receiving message

From Dev

How to prevent receiving broadcast message

From Dev

When trying to build, receiving this error message "error: resource android:attr/fontVariationSettings not found."

From Dev

Not receiving Cloud function FCM message in android 8

Related Related

  1. 1

    ActiveMQ different ways for receiving message

  2. 2

    Threaded SocketServer not receiving second message

  3. 3

    java.lang.RuntimeException: Handler (android.os.Handler) sending message to a Handler on a dead thread

  4. 4

    Android loopj + GCMIntentService sending message to a Handler on a dead thread

  5. 5

    Android - Sending Message to Thread Incoming Handler

  6. 6

    Erlang message receiving order

  7. 7

    The "this" pointer and message receiving in D

  8. 8

    Android stop notification in status bar while receiving message

  9. 9

    When receiving the sms, only the message was displayed but app didnt open - Android

  10. 10

    Receiving "role" and/or "affiliation" with message in SleekXMPP

  11. 11

    Synchronizing message sending and receiving AGSXMPP

  12. 12

    Android Wear - receiving message from Wear without WearableListenerService?

  13. 13

    How to customize Qt Message Handler on Android

  14. 14

    Child process not receiving message

  15. 15

    Android handler remove send message not working

  16. 16

    gcm not receiving message on client side

  17. 17

    Receiving message in a transaction

  18. 18

    android - bluetooth adapter - message handler buffer limit

  19. 19

    Android - What is an Handler Message?

  20. 20

    Message handler not activating

  21. 21

    Android: Delay in Receiving message in FCM(onMessageReceived)

  22. 22

    Android EventBus - Sequence for receiving message

  23. 23

    No-message listener for handler

  24. 24

    Server not receiving message properly?

  25. 25

    Receiving "role" and/or "affiliation" with message in SleekXMPP

  26. 26

    Elixir process not receiving message

  27. 27

    How to prevent receiving broadcast message

  28. 28

    When trying to build, receiving this error message "error: resource android:attr/fontVariationSettings not found."

  29. 29

    Not receiving Cloud function FCM message in android 8

HotTag

Archive