title: Attempt to invoke virtual method 'Bundle.getParcelableArrayList(java.lang.String)' on a null object reference
body: <p>I have MainActivity managing two fragments.from one i am choosing song and from another i am playing it. But when i am trying to run it i am getting runtimeException.</p>
  
  <p>Code for fragment current_song.java :</p>
  
  <pre><code>package com.example.mandar.mediaplayer;
  
  import android.content.Context;
  import android.content.Intent;
  import android.media.MediaPlayer;
  import android.net.Uri;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  import java.io.File;
  import java.util.ArrayList;
  
  
  public class current_song extends Fragment {
  MediaPlayer mp;
  ArrayList&lt;File&gt; mySongs;
  
  
  public current_song() {
      // Required empty public constructor
  }
  
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      View view= inflater.inflate(R.layout.fragment_current_song, container, false);
  
      Intent i=getActivity().getIntent();
      Bundle b=i.getExtras();
  
      mySongs= (ArrayList) b.getParcelableArrayList("songlist");
      int position = b.getInt("pos",0);
  
      Uri u= Uri.parse(mySongs.get(position).toString());
      mp= MediaPlayer.create(getActivity().getApplicationContext(),u);
      mp.start();
  
  
      return view;
  }
  
  
  }
  </code></pre>
  
  <p>Code for fragment songs.java :</p>
  
  <pre><code>public class songs extends ListFragment {
  String(String.valueOf(Environment.getExternalStorageDirectory()));
  ListView lv;
  String[] items;
  
  public songs() {
      // Required empty public constructor
  }
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
  
  
  
  
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      // Inflate the layout for this fragment
  
  
  
      return inflater.inflate(R.layout.fragment_songs, container, false);
  
  
  }
  
  @Override
  public void onViewCreated (View view, Bundle savedInstanceState) {
  lv=getListView();
      // lv = (ListView)view.findViewById(R.id.list);
      final ArrayList&lt;File&gt; mysongs =findsongs(Environment.getExternalStorageDirectory());
      items =new String[ mysongs.size()];
  
      for (int i=0; i&lt;mysongs.size(); i++){
  
          //toast(mysongs.get(i).getName().toString());
          items[i]=mysongs.get(i).getName().toString().replace(".mp3","");
      }
  
      ArrayAdapter&lt;String&gt; adp = new ArrayAdapter&lt;String&gt;(getActivity().getApplicationContext(),R.layout.song_item,R.id.text1,items);
      lv.setAdapter(adp);
      lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
              startActivity(new Intent(getActivity().getApplicationContext(),current_song.class).putExtra("pos",position).putExtra("songlist",mysongs));
  
          }
      });
  
  
  
  
  }
  
  
  public void toast (String text){
      Toast.makeText(getActivity().getApplicationContext(),text,Toast.LENGTH_SHORT).show();
  
  
  }
  
  @Override
  public void onActivityCreated (Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
  
  
  
  }
  
      public ArrayList&lt;File&gt; findsongs(File root){
      ArrayList&lt;File&gt; a1=new ArrayList&lt;File&gt;();
      File[] files=root.listFiles();
      for (File singleFile : files){
          if(singleFile.isDirectory() &amp;&amp; !singleFile.isHidden()){
              a1.addAll(findsongs(singleFile));
  
          }
          else {
              if (singleFile.getName().endsWith(".mp3") || singleFile.getName().endsWith(".wav")){
                  a1.add(singleFile);
              }
          }
      }
      return a1;
  }
  
  }
  </code></pre>
  
  <p>code for fragment_current_song.xml</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.mandar.mediaplayer.current_song"&gt;
  
      &lt;!-- TODO: Update blank fragment layout --&gt;
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal|top"&gt;
  
          &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/imageView"
              android:src="@drawable/abc"
              android:layout_alignParentTop="true"
              android:layout_centerHorizontal="true"
              android:layout_marginTop="119dp" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textAppearance="?android:attr/textAppearanceLarge"
              android:text="Media Player"
              android:id="@+id/textview"
              android:layout_marginTop="61dp"
              android:layout_alignParentTop="true"
              android:layout_centerHorizontal="true" /&gt;
  
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
  
              android:id="@+id/button"
              android:text="&amp;lt;&amp;lt;"
              android:width="70dp"
              android:height="40dp"
              android:layout_alignBaseline="@+id/button2"
              android:layout_alignBottom="@+id/button2"
              android:layout_toLeftOf="@+id/button2"
              android:layout_toStartOf="@+id/button2" /&gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="||"
              android:id="@+id/button2"
              android:width="70dp"
              android:height="40dp"
              android:layout_below="@+id/seekBar"
              android:layout_alignLeft="@+id/imageView"
              android:layout_alignStart="@+id/imageView" /&gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:width="70dp"
              android:height="40dp"
              android:id="@+id/button3"
              android:layout_alignTop="@+id/button"
              android:layout_toRightOf="@+id/button2"
              android:layout_toEndOf="@+id/button2"
              android:text="&gt;" /&gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
  
              android:id="@+id/button4"
              android:text="&gt;&gt;"
              android:width="70dp"
              android:height="40dp"
              android:layout_below="@+id/seekBar"
              android:layout_toRightOf="@+id/button3"
              android:layout_alignParentRight="true"
              android:layout_alignParentEnd="true" /&gt;
  
          &lt;SeekBar
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/seekBar"
  
              android:layout_below="@+id/textView2"
              android:layout_alignParentLeft="true"
              android:layout_alignParentStart="true"
              android:layout_marginTop="25dp"
              android:layout_alignParentRight="true"
              android:layout_alignParentEnd="true" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textAppearance="?android:attr/textAppearanceSmall"
              android:text="Small Text"
              android:id="@+id/textView2"
              android:layout_marginTop="34dp"
              android:layout_below="@+id/imageView"
              android:layout_alignParentLeft="true"
              android:layout_alignParentStart="true" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textAppearance="?android:attr/textAppearanceSmall"
              android:text="Small Text"
              android:id="@+id/textView3"
              android:layout_alignBottom="@+id/textView4"
              android:layout_alignParentRight="true"
              android:layout_alignParentEnd="true" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textAppearance="?android:attr/textAppearanceMedium"
              android:text="Medium Text"
              android:id="@+id/textView4"
  
              android:layout_alignBottom="@+id/textView2"
              android:layout_alignLeft="@+id/textview"
              android:layout_alignStart="@+id/textview" /&gt;
  
      &lt;/RelativeLayout&gt;
  
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>code for fragment_songs.xml</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.mandar.mediaplayer.songs"&gt;
  
      &lt;!-- TODO: Update blank fragment layout --&gt;
  
  
      &lt;ListView
          android:layout_width="wrap_content"
          android:layout_height="440dp"
          android:id="@android:id/list"
          android:layout_gravity="center_horizontal|top" /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>Error Log :</p>
  
  <pre><code>04-17 22:20:34.035 26799-26799/com.example.mandar.mediaplayer E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: com.example.mandar.mediaplayer, PID: 26799
                                                                              java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ArrayList android.os.Bundle.getParcelableArrayList(java.lang.String)' on a null object reference
                                                                                  at com.example.mandar.mediaplayer.current_song.onCreateView(current_song.java:36)
                                                                                  at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
                                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
                                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
                                                                                  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
                                                                                  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
                                                                                  at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
                                                                                  at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
                                                                                  at android.support.v4.view.ViewPager.populate(ViewPager.java:1177)
                                                                                  at android.support.v4.view.ViewPager.populate(ViewPager.java:1025)
                                                                                  at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1545)
                                                                                  at android.view.View.measure(View.java:17637)
                                                                                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                                  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                                                  at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                                                  at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                                                  at android.support.design.widget.AppBarLayout.onMeasure(AppBarLayout.java:199)
                                                                                  at android.view.View.measure(View.java:17637)
                                                                                  at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
                                                                                  at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
                                                                                  at android.view.View.measure(View.java:17637)
                                                                                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                                  at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                                  at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                                                                                  at android.view.View.measure(View.java:17637)
                                                                                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                                  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                                                  at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                                                  at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                                                  at android.view.View.measure(View.java:17637)
                                                                                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                                  at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                                  at android.view.View.measure(View.java:17637)
                                                                                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                                  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                                                  at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                                                  at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                                                  at android.view.View.measure(View.java:17637)
                                                                                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                                  at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                                  at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2618)
                                                                                  at android.view.View.measure(View.java:17637)
                                                                                  at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2019)
                                                                                  at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1177)
                                                                                  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1383)
                                                                                  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1065)
                                                                                  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5901)
                                                                                  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
                                                                                  at android.view.Choreographer.doCallbacks(Choreographer.java:580)
                                                                                  at android.view.Choreographer.doFrame(Choreographer.java:550)
                                                                                  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
                                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                  at android.os.Looper.loop(Looper.java:211)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5389)
  </code></pre>