致命异常:主要 [英] FATAL EXCEPTION: main

查看:99
本文介绍了致命异常:主要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序开发,我正在使用的活动中,我通过使用线程显示逐页列表视图中的项目页面,当用户选择该项目将采取用户到另一个活动。

I am developing in app where I am using an activity in which I'm displaying a list view items page by page by using threading, When the user selects the item it will take the user to another activity.

但在这里,当我的列表视图项单击该应用程序崩溃有时。它说,在日志猫的东西,但我无法理解这一点。

But Here some times when I click on list view item the app crashes. It says something in log cat but I am unable to understand it.

下面是堆栈跟踪:

06-24 16:26:44.320: ERROR/AndroidRuntime(4248): FATAL EXCEPTION: main
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@4073ef78 is not valid; is your activity running?
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at android.view.ViewRoot.setView(ViewRoot.java:527)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at android.app.Dialog.show(Dialog.java:241)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at com.usablenet.mobile.walgreen.app.util.ErrorAlertServiceImp.showErrorAlert(ErrorAlertServiceImp.java:86)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at com.usablenet.mobile.walgreen.pharmacy.PrescriptionList.showErrorCodeAlert(PrescriptionList.java:360)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at com.usablenet.mobile.walgreen.pharmacy.PrescriptionList.access$300(PrescriptionList.java:45)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at com.usablenet.mobile.walgreen.pharmacy.PrescriptionList$2.handleMessage(PrescriptionList.java:323)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at android.os.Looper.loop(Looper.java:130)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at android.app.ActivityThread.main(ActivityThread.java:3683)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248):     at dalvik.system.NativeStart.main(Native Method)

谢谢,
巴鲁。

Thanks, Balu.

推荐答案

使用 getApplicationContext 的AlertDialog,否则在任务之间切换,你会得到这个错误。
而不是: AlertDialog.Builder建设者=新AlertDialog.Builder(本);
用途: ConnectionDetector =新ConnectionDetector(getApplicationContext());
这同样适用于对话框上的任何侦听器。

Use getApplicationContext for the AlertDialog, otherwise you will get this error when you switch between tasks. Instead of: AlertDialog.Builder builder = new AlertDialog.Builder(this); Use:ConnectionDetector = new ConnectionDetector(getApplicationContext()); The same goes for any listeners on the dialog.

此外:

if (!ConnectionDetector.isConnectingToInternet()) {
alert.showAlertDialog(ListActivity.this, "Internet Connection Error","Please connect to working Internet connection", false);
            // stop executing code by return
            return;
        }

这篇关于致命异常:主要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆