title: How to call Fragment from Fragment along with data
body: <p>Earlier I was calling Activity from Fragment along with data, using below code:</p>
  
  <p><strong>ListCategoryFragment.java :</strong></p>
  
  <pre><code>          case categoryFirst:
               Intent intent1 = new Intent(getActivity(), ListItemActivity.class);
               intent1.putExtra("category", "Category - 1");
               startActivity(intent1);    
             break;
  </code></pre>
  
  <p><strong>ListItemActivity.java :</strong></p>
  
  <pre><code>    Bundle bdl = getActivity().getIntent().getExtras();
      KEY_CATEGORY = bdl.getString("category");
  </code></pre>
  
  <p>But now i am Calling Fragment from Fragment, using below code:</p>
  
  <p><strong>ListCategoryFragment.java :</strong></p>
  
  <pre><code>private static final int categoryFirst = 0;
  
  public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long id) {
  
      // Set up different intents based on the item clicked: 
      switch (position)
      {
  
             case categoryFirst:
                  ListItemFragment fragment1 = new ListItemFragment();
                  Bundle bundle = new Bundle();
                  bundle.putString("category", "Category - 1");
                  fragment1.setArguments(bundle);
                  FragmentManager fragmentManager = getFragmentManager();
                  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                 fragmentTransaction.replace(android.R.id.content, fragment1);
                  fragmentTransaction.commit();
               break;
  
             default:
               break;
      }
  </code></pre>
  
  <p><strong>ListItemFragment.java :</strong></p>
  
  <pre><code>        Bundle bdl = getActivity().getIntent().getExtras();
          KEY_CATEGORY = bdl.getString("category");  // Line No. - 67
  </code></pre>
  
  <p><strong>Log Says:</strong></p>
  
  <pre><code>10-22 02:06:06.930: W/dalvikvm(914): threadid=1: thread exiting with uncaught exception (group=0x41465700)
  10-22 02:06:06.959: E/AndroidRuntime(914): FATAL EXCEPTION: main
  10-22 02:06:06.959: E/AndroidRuntime(914): java.lang.NullPointerException
  10-22 02:06:06.959: E/AndroidRuntime(914):  at com.androidbegin.absviewpagertutorial.ListItemFragment.onCreateView(ListItemFragment.java:67)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:870)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at android.os.Handler.handleCallback(Handler.java:730)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at android.os.Handler.dispatchMessage(Handler.java:92)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at android.os.Looper.loop(Looper.java:137)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at android.app.ActivityThread.main(ActivityThread.java:5103)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at java.lang.reflect.Method.invokeNative(Native Method)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at java.lang.reflect.Method.invoke(Method.java:525)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  10-22 02:06:06.959: E/AndroidRuntime(914):  at dalvik.system.NativeStart.main(Native Method)
  10-22 02:06:09.900: I/Process(914): Sending signal. PID: 914 SIG: 9
  </code></pre>