java.lang.IllegalStateException:在死线程上向处理程序发送消息

时间:2018-07-01 15:34:53

标签: android exception-handling android-handler

我开发了一款使用大量处理程序的游戏。我正在使用admob插页式广告。当游戏级别被清除时,我会显示插页式广告,但是当我关闭广告时,会抛出异常,这我无法弄清楚出

仅当我关闭插页式广告时才会引发异常。

代码:

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);
    }
});

例外是:

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)

0 个答案:

没有答案