Search code examples
javaandroidandroid-7.1-nougat

Android - Two Actvities can't get Bundle Extras out of Nine


So I have 9 activities that started out as copy and pastes of each other. As far as I can tell they really only differ in the number of check boxes and text fields on them. Two of the activities can't receive Bundle Extras and it has me stumped. I can move freely between the 7 working activities but the last two wont receive Bundle Extras from any of the other activities.

The only information that is being passed about is one int.

Sender Example

myIntent = new Intent(getBaseContext(), PostSession.class);
output.putInt("flightId", mFlightInfoId);
startActivity(myIntent);
overridePendingTransition(0, 0);

Receiver Example from one of the non-working activities

Bundle extras = getIntent().getExtras();
mFlightInfoId = extras.getInt("flightId");

Error Message

java.lang.RuntimeException: Unable to start activity ComponentInfo{project.xyz.logging/project.xyz.logging.PostSession}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.os.Bundle.getInt(java.lang.String)' on a null object reference


Solution

  • Just like @Napster said I forgot to put the output bundle into the Intent