title: How to get the ID of a fragment?
body: <p>First of all, I followed <a href="http://arvid-g.de/12/android-4-actionbar-with-tabs-example" rel="noreferrer">this tutorial</a> to create an activity with an actionbar+tabs. What this implementation does is that it has a fragment_container (just a linear layout) in the main_activity layout and it replaces it with a fragment depending on what tab is selected.</p>
  
  <p>Now, I'm trying to add some <a href="http://developer.android.com/training/basics/fragments/communicating.html#Deliver" rel="noreferrer">fragment-to-activity communication</a> but I'm getting a nullpointerexemption.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>com.mypackage.MAPFragment map_ =
  (com.mypackage.MAPFragment) getFragmentManager().findFragmentById(R.id.map);
  map_.ActivityToMapMethod();
  </code></pre>
  
  <p>The <strong>MAPFragment</strong> fragment inflates a xml layout that has a mapView with and id of <strong>map</strong>. I'm not so sure if the <strong>map</strong> id is what I'm supposed to be using. I've successfully done this before in another app but that time the fragment was added via xml, and not by using replace().</p>