FATAL EXCEPTION: main
ava.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=291, result=801, data=Intent { cmp=com.example.simplecalc/.CalculationTypeActivity (has extras) }} to activity {com.example.simplecalc/com.example.simplecalc.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3367)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3410)
at android.app.ActivityThread.access$1100(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.simplecalc.MainActivity.onActivityResult(MainActivity.java:49)
at android.app.Activity.dispatchActivityResult(Activity.java:5322)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3363)
... 11 more
错误之处通过Log.d()等Log函数定位,发现很简单的是
calcTypeText.setText(ConstantInfo.typeMap.get(calcType));
中TextView变量calcTypeText没有和界面TextView对象绑定。
关键时注意错误信息中的java.lang.NullPointerException,指针为null抛出的异常。