title: Implement an Interface which extends Parcelable
body: <p>I want to send a <code>listener</code> from an <code>adapter</code> to <code>fragment</code>. As android suggests not to use constructors i'm sending listener through <code>setArguments()</code>.</p>
  
  <p>I'm unable to <code>implement</code> this listener properly.</p>
  
  <p>This is mycode</p>
  
  <p><strong>Listener:</strong></p>
  
  <pre><code>public interface DiscoverFragmentListener extends Parcelable{
  
      void onSwitchToNextFragment();
  }
  </code></pre>
  
  <p><strong>Implementation:</strong></p>
  
  <pre><code>public final class DiscoverpageListener implements DiscoverFragmentListener {
              @Override
              public void onSwitchToNextFragment() {
                  mFragmentManager.beginTransaction().remove(mFragmentAtPos0)
                          .commit();
                  if (mFragmentAtPos0 instanceof DummySectionFragment) {
                      Button_Description frag = new Button_Description();
                      Bundle basket = new Bundle();
                      basket.putParcelable("listener",listener);
                      frag.setArguments(basket);
                      mFragmentAtPos0 = frag;
                  } else { // Instance of NextFragment
                      DummySectionFragment frag = new DummySectionFragment();
                      Bundle basket = new Bundle();
                      basket.putParcelable("listener",listener);
                      frag.setArguments(basket);
                      mFragmentAtPos0 = frag;
                  }
                  notifyDataSetChanged();
              }
  
              @Override
              public int describeContents() {
                  return 0;
              }
  
              @Override
              public void writeToParcel(Parcel dest, int flags) {
  
              }
          }
  </code></pre>
  
  <p><strong>DummySectionFragment:</strong></p>
  
  <pre><code>public static class DummySectionFragment extends Fragment{
  
  
  
          private DiscoverFragmentListener discoverFragmentListener;
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              View rootView = inflater.inflate(R.layout.discover_fragment, container, false);
  
              discoverFragmentListener = getArguments().getParcelable("listener");
  return rootView;
  </code></pre>
  
  <p><strong>I'm getting this error:</strong></p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Parcelable android.os.Bundle.getParcelable(java.lang.String)' on a null object reference
  </code></pre>
  
  <p>Help me out!</p>
  
  <p>Thanks!</p>