java.lang.IllegalStateException: sending message to a Handler on a dead thread


java.lang.IllegalStateException: sending message to a Handler on a dead thread



I have developed a game which makes use of lots of handlers.I am using admob interstitial ads.When a game level is cleared i show the interstitial ad but when i close the ad exception is thrown which i am not able to figure out



The Exception is thrown only when i close the interstitial ad.



Code :


collectORCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isCollectPressed = true;
soundPlayer.playClickSound();
Utils.getInstance().playClickAnimation(v);
handler.postDelayed(new Runnable() {
@Override
public void run() {
addCandy();
dialog.dismiss();
getActivity().getSupportFragmentManager().popBackStack();

handler.postDelayed(new Runnable() {
@Override
public void run() {
Utils.getInstance().showInterStitialAd(BaseApp.getInstance());
}
},800);

}
},300);
}
});



The Exception is :


java.lang.IllegalStateException: Handler (android.os.Handler) {883c1c2} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:634)
at android.os.Handler.sendMessageAtTime(Handler.java:600)
at android.os.Handler.sendMessageDelayed(Handler.java:570)
at android.os.Handler.sendEmptyMessageDelayed(Handler.java:534)
at android.os.Handler.sendEmptyMessage(Handler.java:519)
at com.google.android.gms.ads.internal.video.exoplayer1.f.b(:com.google.android.gms.dynamite_dynamitemodulesa@12685024@12.6.85 (040406-197041431):174)
at com.google.android.gms.ads.internal.webview.t.u(:com.google.android.gms.dynamite_dynamitemodulesa@12685024@12.6.85 (040406-197041431):22)
at com.google.android.gms.ads.internal.webview.j.onPageFinished(:com.google.android.gms.dynamite_dynamitemodulesa@12685024@12.6.85 (040406-197041431):84)
at com.android.webview.chromium.WebViewContentsClientAdapter.onPageFinished(WebViewContentsClientAdapter.java:224)
at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:72)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5555)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Rothschild family

Cinema of Italy