一旦用户通过意图登录并使用Bundle接收它,我目前正在发送一个变量。
我已经检查了 LogCat 并收到了变量,但是一旦我收到它,应用程序就会崩溃......下面是我的代码。
Bundle bundle = getIntent().getExtras();
final int cameraId = 0;
final TextView welcomeText = (TextView) findViewById(R.id.WelcomeText);
final TextView relocationId = (TextView) findViewById(R.id.RelocationID);
final TextView addressOne = (TextView) findViewById(R.id.addressOne);
final TextView addressTwo = (TextView) findViewById(R.id.addressTwo);
final String RelocationId = bundle.getString("UID");
relocationId.setText("Your Relocation: #" + RelocationId);
这就是我的包在接收端的样子(但之后崩溃)。如果我注释掉最后两行,它会像往常一样继续。
日志猫:
03-25 18:35:50.749: E/AndroidRuntime(19145): FATAL EXCEPTION: main
03-25 18:35:50.749: E/AndroidRuntime(19145): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.testingapp/com.testingapp.MoveContactsActivity}: java.lang.NullPointerException
03-25 18:35:50.749: E/AndroidRuntime(19145): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
03-25 18:35:50.749: E/AndroidRuntime(19145): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-25 18:35:50.749: E/AndroidRuntime(19145): at android.app.ActivityThread.access$600(ActivityThread.java:140)
03-25 18:35:50.749: E/AndroidRuntime(19145): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-25 18:35:50.749: E/AndroidRuntime(19145): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 18:35:50.749: E/AndroidRuntime(19145): at android.os.Looper.loop(Looper.java:137)
03-25 18:35:50.749: E/AndroidRuntime(19145): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-25 18:35:50.749: E/AndroidRuntime(19145): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 18:35:50.749: E/AndroidRuntime(19145): at java.lang.reflect.Method.invoke(Method.java:511)
03-25 18:35:50.749: E/AndroidRuntime(19145): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
03-25 18:35:50.749: E/AndroidRuntime(19145): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
03-25 18:35:50.749: E/AndroidRuntime(19145): at dalvik.system.NativeStart.main(Native Method)
03-25 18:35:50.749: E/AndroidRuntime(19145): Caused by: java.lang.NullPointerException
03-25 18:35:50.749: E/AndroidRuntime(19145): at com.testingapp.MoveContactsActivity.onCreate(MoveContactsActivity.java:69)
03-25 18:35:50.749: E/AndroidRuntime(19145): at android.app.Activity.performCreate(Activity.java:5206)
03-25 18:35:50.749: E/AndroidRuntime(19145): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
03-25 18:35:50.749: E/AndroidRuntime(19145): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-25 18:35:50.749: E/AndroidRuntime(19145): ... 11 more
怎么了?