Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCMIntentService + sending message to a Handler on a dead thread

My app works correctly, but I'm facing the following error:

10-04 14:04:38.182: W/MessageQueue(8625): Handler (android.media.MediaPlayer$EventHandler){416ad6b0} sending message to a Handler on a dead thread
10-04 14:04:38.182: W/MessageQueue(8625): java.lang.RuntimeException: Handler (android.media.MediaPlayer$EventHandler) {416ad6b0} sending message to a Handler on a dead thread
10-04 14:04:38.182: W/MessageQueue(8625):   at android.os.MessageQueue.enqueueMessage(MessageQueue.java:196)
10-04 14:04:38.182: W/MessageQueue(8625):   at android.os.Handler.sendMessageAtTime(Handler.java:473)
10-04 14:04:38.182: W/MessageQueue(8625):   at android.os.Handler.sendMessageDelayed(Handler.java:446)
10-04 14:04:38.182: W/MessageQueue(8625):   at android.os.Handler.sendMessage    (Handler.java:383)
10-04 14:04:38.182: W/MessageQueue(8625):   at android.media.MediaPlayer.postEventFromNative(MediaPlayer.java:1898)
10-04 14:04:38.182: W/MessageQueue(8625):   at dalvik.system.NativeStart.run(Native Method)
10-04 14:04:38.182: V/MediaPlayer(8625): back from callback

I already saw this thread and the proposed workaround, but it doesn't work for me.

Anybody has another solution?

like image 464
jobe Avatar asked Oct 22 '22 07:10

jobe


1 Answers

 // create a handler to post messages to the main thread
 Handler mHandler = new Handler(getMainLooper());
 mHandler.post(new Runnable() {
     @Override
    public void run() {
        Toast.makeText(getApplicationContext(), "hello", Toast.LENGTH_SHORT).show();
    }
 });

Try This Code Hope It helps

like image 68
Hardik Amal Avatar answered Oct 31 '22 11:10

Hardik Amal