这是我尝试在两个活动之间传递变量后的错误
例子:
主要活动
Intent KMH = new Intent(Options.this,VolumeControlMAIN.class);
Bundle DistanceValue = new Bundle();
DistanceValue.putBoolean("distance", DistanceTX);
KMH.putExtras(DistanceValue);
startActivity(KMH);
第二次活动
Bundle distanceK = getIntent().getExtras();
value = distanceK.getBoolean("distance");
这是我的日志猫。
08-28 11:36:18.923: E/AndroidRuntime(841): FATAL EXCEPTION: main
08-28 11:36:18.923: E/AndroidRuntime(841): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.audiovolumecontrol/com.example.audiovolumecontrol.VolumeControlMAIN}: java.lang.NullPointerException
08-28 11:36:18.923: E/AndroidRuntime(841): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
08-28 11:36:18.923: E/AndroidRuntime(841): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
08-28 11:36:18.923: E/AndroidRuntime(841): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-28 11:36:18.923: E/AndroidRuntime(841): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-28 11:36:18.923: E/AndroidRuntime(841): at android.os.Handler.dispatchMessage(Handler.java:99)
08-28 11:36:18.923: E/AndroidRuntime(841): at android.os.Looper.loop(Looper.java:137)
08-28 11:36:18.923: E/AndroidRuntime(841): at android.app.ActivityThread.main(ActivityThread.java:5041)
08-28 11:36:18.923: E/AndroidRuntime(841): at java.lang.reflect.Method.invokeNative(Native Method)
08-28 11:36:18.923: E/AndroidRuntime(841): at java.lang.reflect.Method.invoke(Method.java:511)
08-28 11:36:18.923: E/AndroidRuntime(841): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-28 11:36:18.923: E/AndroidRuntime(841): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-28 11:36:18.923: E/AndroidRuntime(841): at dalvik.system.NativeStart.main(Native Method)
08-28 11:36:18.923: E/AndroidRuntime(841): Caused by: java.lang.NullPointerException
08-28 11:36:18.923: E/AndroidRuntime(841): at com.example.audiovolumecontrol.VolumeControlMAIN.onCreate(VolumeControlMAIN.java:144)
08-28 11:36:18.923: E/AndroidRuntime(841): at android.app.Activity.performCreate(Activity.java:5104)
08-28 11:36:18.923: E/AndroidRuntime(841): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-28 11:36:18.923: E/AndroidRuntime(841): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
08-28 11:36:18.923: E/AndroidRuntime(841): ... 11 more
我是否必须为要解析的每个变量创建一个意图,或者我可以使用全局意图并一次通过所有变量?
谁能确定我的日志猫要我做什么?