I'm trying to create a set up sequence for my signing up process where on the first page (activity) the user's email and password is stored as extra's in an intent. These extra's are then stored as variables in the second page. Then on the second page more details are asked of the user while still adding these as extra's to a new intent along with the extra's from the first page. Then these new extra's are stored as variables in the third activity while more information is collected from the user. Then finally all of the variables stored from this activity and the activities before (from 'getExtras' etc) are stored in the backend after a click of a button. But on this click the app crashes. Any reason as to why?
I have 3 activities; SignUpActivity1, SignUpActivity2 and SignUpActivity3.
In SignUpActivity1 on the click of a button I do;
Intent intent = new Intent(SignUpActivity1.this, SignUpActivity2.class);
intent.putExtra("KEY_ONE", "valueone");
startActivity(intent);
In SignUpActivity2 i then get this intent with;
Intent originalIntent = getIntent();
String value_one = originalIntent.getExtras().getString("KEY_ONE");
Intent intent_two = new Intent(SignUpActivity2.this, SignUpActivity3.class);
intent_two.putExtra("KEY_ONE_AGAIN", value_one):
intent_two.putExtra("KEY_TWO", "newvalue");
startActivity(intent_two);
Then in SignUpActivity3 I wish to obtain these two extra's and store them in variables which can be used, but when I use the variables I run into an error.
Logcat says:
07-09 21:16:03.105: E/AndroidRuntime(2378): FATAL EXCEPTION: main 07-09 21:16:03.105: E/AndroidRuntime(2378): Process: com.example.testproject, PID: 2378 07-09 21:16:03.105: E/AndroidRuntime(2378): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testproject/com.example.testproject.SignUpActivity2}: java.lang.NullPointerException 07-09 21:16:03.105: E/AndroidRuntime(2378): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 07-09 21:16:03.105: E/AndroidRuntime(2378): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 07-09 21:16:03.105: E/AndroidRuntime(2378): at android.app.ActivityThread.access$800(ActivityThread.java:135) 07-09 21:16:03.105: E/AndroidRuntime(2378): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 07-09 21:16:03.105: E/AndroidRuntime(2378): at android.os.Handler.dispatchMessage(Handler.java:102) 07-09 21:16:03.105: E/AndroidRuntime(2378): at android.os.Looper.loop(Looper.java:136) 07-09 21:16:03.105: E/AndroidRuntime(2378): at android.app.ActivityThread.main(ActivityThread.java:5017) 07-09 21:16:03.105: E/AndroidRuntime(2378): at java.lang.reflect.Method.invokeNative(Native Method) 07-09 21:16:03.105: E/AndroidRuntime(2378): at java.lang.reflect.Method.invoke(Method.java:515) 07-09 21:16:03.105: E/AndroidRuntime(2378): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 07-09 21:16:03.105: E/AndroidRuntime(2378): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 07-09 21:16:03.105: E/AndroidRuntime(2378): at dalvik.system.NativeStart.main(Native Method) 07-09 21:16:03.105: E/AndroidRuntime(2378): Caused by: java.lang.NullPointerException 07-09 21:16:03.105: E/AndroidRuntime(2378): at com.example.testproject.SignUpActivity2.onCreate(SignUpActivity2.java:23) 07-09 21:16:03.105: E/AndroidRuntime(2378): at android.app.Activity.performCreate(Activity.java:5231) 07-09 21:16:03.105: E/AndroidRuntime(2378): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 07-09 21:16:03.105: E/AndroidRuntime(2378): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 07-09 21:16:03.105: E/AndroidRuntime(2378): ... 11 more