title: Fragment's onCreate and onCreateView are not called
body: <p>I'm building an application which receive an action.SEND <code>Intent</code> and display all files in clip data into a <code>ListView</code>. My <code>ListView</code> is inside a <code>ShareFragment</code> which hosted by my <code>MainActiviy</code>. Below is how i implement it.</p>
  
  <pre><code>public class ShareFragment extends MFragment {
  
      private static final String TAG = "ShareFragment";
      private List&lt;File&gt; files;
      private FileAdapter fileAdapter;
  
      @Override
      public void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          Log.e(TAG, "onCreate called");
      }
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          files = new ArrayList&lt;&gt;();
          fileAdapter = new FileAdapter(getActivity(), 0, files);
          View rootView = inflater.inflate(R.layout.share_fragment, container, false);
          ListView lv = (ListView) rootView.findViewById(R.id.listView);
          lv.setAdapter(fileAdapter);
          Log.e(TAG, "onCreateView called");
          return rootView;
      }
  
      public void setData(List&lt;File&gt; files){
          Log.e(TAG, "setData called");
          this.files = files;
          fileAdapter.notifyDataSetChanged();
      }
  </code></pre>
  
  <p>And here is how i used it in <code>MainActivity</code></p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Intent intent = getIntent();
          shareFragment = (ShareFragment) getSupportFragmentManager().findFragmentByTag("share_fragment");
          if(shareFragment == null) {
              shareFragment = new ShareFragment();
              shareFragment.setTitle("Share");
          }
          FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
          ft.add(R.id.fl_root, shareFragment, "share_fragment");
          ft.commit();
          handleIntent(intent);
      }
  </code></pre>
  
  <p>Here is <code>handleIntent</code> method:</p>
  
  <pre><code>private void handleIntent(Intent intent) {
      String action = intent.getAction();
      String type = intent.getType();
      if ((Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) &amp;&amp; type != null) {
          int size = intent.getClipData().getItemCount();
          List&lt;File&gt; files = new ArrayList&lt;&gt;();
          for (int i = 0; i &lt; size; i++) {
              File file = new File(intent.getClipData().getItemAt(i).getUri().getPath());
              files.add(file);
          }
          shareFragment.setData(files);
      }
  }
  </code></pre>
  
  <p><strong><em>My problem is</em></strong>
  When my application are started by receive an <code>action.SEND</code> <code>Intent</code>, it ran into <code>onCreate</code> and processed this line <code>shareFragment = new ShareFragment()</code></p>
  
  <p><strong>But</strong>
  <code>onCreate</code> and <code>onCreateView</code> of <code>ShareFragment</code> is never called. <strong>why?</strong></p>
  
  <p><strong>Note</strong> I thought the <code>FragmentManager</code> kept an instance of <code>ShareFragment</code> when my app first ran. So i try to found my fragment to reused it, but it always returned null. </p>
  
  <p><strong>EDIT</strong>
  I got a <code>NullPointerException</code> right at <code>fileAdapter.notifyDataSetChanged();</code></p>
  
  <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void icetea.com.quickshare.adapter.FileAdapter.notifyDataSetChanged()' on a null object reference
              at icetea.com.quickshare.fragments.ShareFragment.setData(ShareFragment.java:49)
              at icetea.com.quickshare.MainActivity.handleIntent(MainActivity.java:63)
              at icetea.com.quickshare.MainActivity.onCreate(MainActivity.java:46)
              at android.app.Activity.performCreate(Activity.java:6374)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2767)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2879)
              at android.app.ActivityThread.access$900(ActivityThread.java:182)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:145)
              at android.app.ActivityThread.main(ActivityThread.java:6141)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
  </code></pre>