Home » Android » android – sending message to a Handler on a dead thread Google Admob Rewarded video

android – sending message to a Handler on a dead thread Google Admob Rewarded video

Posted by: admin May 14, 2020 Leave a comment

Questions:

I got this stacktrace while I came back to my activity from Google Admob’s rewarded video screen after completing whole video. Its just warning, not crash.
onRewardedVideoAdClosed() method is called after watching video, but onRewarded() does not called. Any help??

  Handler (android.os.Handler) {5451758} sending message to a Handler on a dead thread
    06-06 09:29:00.378: W/MessageQueue(10743): java.lang.IllegalStateException: Handler (android.os.Handler) {5451758} sending message to a Handler on a dead thread
    06-06 09:29:00.378: W/MessageQueue(10743):  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
    06-06 09:29:00.378: W/MessageQueue(10743):  at android.os.Handler.enqueueMessage(Handler.java:631)
    06-06 09:29:00.378: W/MessageQueue(10743):  at android.os.Handler.sendMessageAtTime(Handler.java:600)
    06-06 09:29:00.378: W/MessageQueue(10743):  at android.os.Handler.sendMessageDelayed(Handler.java:570)
    06-06 09:29:00.378: W/MessageQueue(10743):  at android.os.Handler.sendEmptyMessageDelayed(Handler.java:534)
    06-06 09:29:00.378: W/MessageQueue(10743):  at android.os.Handler.sendEmptyMessage(Handler.java:519)
    06-06 09:29:00.378: W/MessageQueue(10743):  at jm.c(:com.google.android.gms.DynamiteModulesA:2142)
    06-06 09:29:00.378: W/MessageQueue(10743):  at ahf.f(:com.google.android.gms.DynamiteModulesA:638)
    06-06 09:29:00.378: W/MessageQueue(10743):  at avj.b(:com.google.android.gms.DynamiteModulesA:1343)
    06-06 09:29:00.378: W/MessageQueue(10743):  at avt.s(:com.google.android.gms.DynamiteModulesA:79)
    06-06 09:29:00.378: W/MessageQueue(10743):  at avl.onPageFinished(:com.google.android.gms.DynamiteModulesA:381)
    06-06 09:29:00.378: W/MessageQueue(10743):  at com.android.webview.chromium.WebViewContentsClientAdapter.onPageFinished(WebViewContentsClientAdapter.java:524)
    06-06 09:29:00.378: W/MessageQueue(10743):  at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:188)
    06-06 09:29:00.378: W/MessageQueue(10743):  at android.os.Handler.dispatchMessage(Handler.java:102)
    06-06 09:29:00.378: W/MessageQueue(10743):  at android.os.Looper.loop(Looper.java:148)
    06-06 09:29:00.378: W/MessageQueue(10743):  at android.app.ActivityThread.main(ActivityThread.java:5443)
    06-06 09:29:00.378: W/MessageQueue(10743):  at java.lang.reflect.Method.invoke(Native Method)
    06-06 09:29:00.378: W/MessageQueue(10743):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    06-06 09:29:00.378: W/MessageQueue(10743):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    06-06 09:29:00.378: W/ExoPlayerImplInternal(10743): Sent message(1) after release. Message ignored.
How to&Answers:

Recently I was working with Google AdMob Reward video. My app was crashing after reward video was displayed.
The actual reason was, the “onVideoClosed” callback gets invoked from the background thread and from the background thread I was mistakenly updating an UI element, which must be done via Main thread.

So, please check if there are any UI elements being updated by any means from background thread.

Answer:

i got the same error when i was using ad reward in 2 activities.
I searched and found
http://qaru.site/questions/1677496/admob-android-rewarded-video-not-showing-sometimes

the easy way out is not using

 mRewardedVideoAd.destroy(this);
or 
 mRewardedVideoAd.destroy(getApplicationContext());

in onDestroy()
even if in the official documentation it is written that you have to….