Intent.getSerializableExtra is returning null
<p>I'm trying to send two custom objects, one that stores an instance of another, along with an intent to another activity. Both of these implement Serializable, like so:</p>

<pre><code>public class Story implements Serializable {

    private String title, author;
    private ArrayList&lt;StorySegment&gt; segments;

... }


class StorySegment implements Serializable {

    private String author;
    private String contents;

... }
</code></pre>

<p>And in my StoryOverviewAdapter class, I've got this:</p>

<pre><code>public class StoryOverviewAdapter extends ArrayAdapter&lt;Story&gt; {

    public StoryOverviewAdapter(Context ctx, ArrayList&lt;Story&gt; stories) {
        super(ctx, 0, stories);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(getContext()).inflate(
                    R.layout.story_overview_item, parent, false);
        }

        final Story story = getItem(position);

        TextView tvStoryTitle = (TextView) convertView.findViewById(R.id.tv_story_title);
        tvStoryTitle.setText(story.getTitle());
        TextView tvStoryOpening = (TextView) convertView.findViewById(R.id.tv_story_opening);
        tvStoryOpening.setText(story.getSegment(0).getContents());

        ImageView ivUserPicture = (ImageView) convertView.findViewById(R.id.iv_user_picture);
        ivUserPicture.setTag(position);
        ivUserPicture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Show user profile
            }
        });

        LinearLayout llStoryLayout = (LinearLayout) convertView.findViewById(R.id.story_layout);
        llStoryLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(v.getContext(), StoryActivity.class);
                    intent.putExtra("story", story);
                getContext().startActivity(intent);
            }
        });

        return convertView;
    }
}
</code></pre>

<p>When I go to pull this information from my Intent in the receiving activity...</p>

<pre><code>Intent intent = getIntent();
Story story = (Story) intent.getSerializableExtra("story");
</code></pre>

<p>... And then try to test my code, I get this:</p>

<pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.Serializable android.content.Intent.getSerializableExtra(java.lang.String)' on a null object reference
</code></pre>

<p>And I have no idea why. I thought maybe removing 'final' from the story variable would get rid of it, but I can't access the variable from inside my inner OnClickListener class without it. Not sure what to do.</p>

<p>EDIT: Also, here's the code that shows that I've added a story...</p>

<pre><code>public class OverviewActivity extends AppCompatActivity {

    ArrayList&lt;Story&gt; stories = new ArrayList&lt;Story&gt;();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_overview);

        stories.add(new Story("Lorem Ipsum", "Firstname Lastname",
                new StorySegment("Firstname Lastname", "Lorem ipsum dolor sit amet, lorem ipsum dolor sit amet, lorem ipsum dolor sit amet...")));

        StoryOverviewAdapter storyOverviewAdapter = new StoryOverviewAdapter(this, stories);
        ListView listView = (ListView) findViewById(R.id.story_overview_list);
        listView.setAdapter(storyOverviewAdapter);
    }
}
</code></pre>