title: Passing an int value from an Activity Fragment to another Fragment
body: <p>I need to pass an int value from an activity fragment to another fragment. This data will be then set to be in a switch case, which will decide on which android layout file will attach to the fragment.</p>
  
  <p>This is the code from the base activity and on the fragment that sets the value to be passed:</p>
  
  <pre><code>Fragment fragment = new otherFragment();
  Bundle bundle = new Bundle();
  bundle.putInt(key, value);
  fragment.setArguments(bundle);
  </code></pre>
  
  <p>btw, I also tried to put the above code on the onCreate and onCreateView method of the fragment but still the same output. then after setting the fragment and the bundle, i switch to the other activity and here is the code that will get and use the int value:</p>
  
  <pre><code>Bundle bundle = this.getArguments();
  int myInt = bundle.getInt(key, defaultValue);
  </code></pre>
  
  <p>also tried</p>
  
  <pre><code>savedInstanceState = this.getArguments();
  int type = savedInstanceState.getInt(key, defaultValue);
  </code></pre>
  
  <p>when from the base activity, the error is Null Pointer Exception, and when from the 1st fragment, the error is Resource not found.</p>
  
  <pre><code>05-12 14:50:47.732: E/ERRORSKI(814): java.lang.NullPointerException
  05-12 14:41:38.542: E/ERRORSKI(798): android.content.res.Resources$NotFoundException: String resource ID #0x1
  </code></pre>
  
  <p>Thank you.</p>