我創建了3個活動。應用程序拋出一個NullPointerException
ElecBillActivity
AddBillActivity
ResultActivity
我成功地照耀處進入第二活動使用的意圖,但只要我單擊第二個活動Submit按鈕,我收到一個例外。
我嘗試了很多方法,但是我無法理解這個問題。
這是我的logcat
E/AndroidRuntime( 506): FATAL EXCEPTION: main
E/AndroidRuntime( 506): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sai.android.billing/com.sai.android.billing.ResultActivity}: java.lang.NullPointerException
E/AndroidRuntime( 506): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1544)
E/AndroidRuntime( 506): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
E/AndroidRuntime( 506): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 506): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
E/AndroidRuntime( 506): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 506): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 506): at android.app.ActivityThread.main(ActivityThread.java:3647)
E/AndroidRuntime( 506): at java.lang.reflect.Method.invokeNative(NativeMethod)
E/AndroidRuntime( 506): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 506): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 506): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 506): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 506): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 506): at com.sai.android.billing.ResultActivity.<init>(ResultActivity.java:21)
E/AndroidRuntime( 506): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime( 506): at java.lang.Class.newInstance(Class.java:1409)
E/AndroidRuntime( 506): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 506): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1536)
E/AndroidRuntime( 506): ... 11 more
W/ActivityManager( 70): Force finishing activity com.sai.android.billing/.ResultActivity
W/ActivityManager( 70): Force finishing activity com.sai.android.billing/.AddBillActivity
W/ActivityManager( 70): Activity pause timeout for HistoryRecord{4079d8f8 com.sai.android.billing/.ResultActivity}
I/ARMAssembler( 70): generated scanline__00000177:03515104_00001001_00000000 [91 ipp] (114 ins) at [0x445b36e0:0x445b38a8] in 1634844 ns
I/Process ( 506): Sending signal. PID: 506 SIG: 9
I/ActivityManager( 70): Process com.sai.android.billing (pid 506) has died.
E/InputDispatcher( 70): channel '4060e840 com.sai.android.billing/com.sai.android.billing.ElecBillingActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8
E/InputDispatcher( 70): channel '4060e840 com.sai.android.billing/com.sai.android.billing.ElecBillingActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
I/WindowManager( 70): WIN DEATH: Window{4060e840 com.sai.android.billing/com.sai.android.billing.ElecBillingActivity paused=false}
I/WindowManager( 70): WIN DEATH: Window{406f4868 com.sai.android.billing/com.sai.android.billing.AddBillActivity paused=true}
E/InputDispatcher( 70): Received spurious receive callback for unknown input channel. fd=151, events=0x8
W/InputManagerService( 70): Got RemoteException sending setActive(false) notification to pid 506 uid 10038
我也提供了鏈接,我code。
由於我的問題似乎很大,我的班級文件太大,我在此處提供了下載鏈接。
由於我是新用戶,因此無法在此處發佈屏幕截圖。
請張貼在這個問題你的代碼的相關部分。它應該在LogCat輸出判斷的ResultActivity類的第21行左右。 – 2011-04-07 10:12:05