如何实现运行时错误?

时间:2011-04-06 05:36:31

标签: android

04-06 10:31:26.835: ERROR/AndroidRuntime(9248): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.transportation/com.transportation.ViewUserDetailsActivity}: java.lang.NullPointerException
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at android.os.Looper.loop(Looper.java:123)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at java.lang.reflect.Method.invokeNative(Native Method)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at java.lang.reflect.Method.invoke(Method.java:521)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at dalvik.system.NativeStart.main(Native Method)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248): Caused by: java.lang.NullPointerException
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at com.transportation.ViewUserDetailsActivity.onCreate(ViewUserDetailsActivity.java:44)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-06 10:31:26.835: ERROR/AndroidRuntime(9248):     ... 11 more

1 个答案:

答案 0 :(得分:0)

java.lang.NullPointerException(第1行)所以如果你想处理那个错误,你应该首先检查一些引用是不是NULL