title: Android Map Fragment inside MainActivity doesn't call onMapReady
body: <p>I made a map FragmentActivity and I want to display it in MainActivity so I can have other elements in the activity. </p>
  
  <p>When I run the app the map starts, but it doesn't fire the onMapReady, hence it's just a basic map in which I cannot move put markers or move the camera programmatically.</p>
  
  <p>The code is really basic, I just put the map in the MainActivity XML.</p>
  
  <pre><code>&lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:map="http://schemas.android.com/apk/res-auto"
                xmlns:tools="http://schemas.android.com/tools"
                android:id="@+id/map"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="4"
                tools:context="com.crisser.beitnaonline.MapsActivity"/&gt;
  </code></pre>
  
  <p>Any idea why it doesn't work?</p>
  
  <p><strong>MainActivity code:</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity implements 
  OnMapReadyCallback
  {
  
  private FirebaseDatabase firebaseDatabase;
  private DatabaseReference firebaseRef;
  private GoogleMap mMap;
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      if (AccessToken.getCurrentAccessToken() == null)
      {
          goLoginScreen();
      }
  
      firebaseDatabase = FirebaseDatabase.getInstance();
      firebaseRef = firebaseDatabase.getReference().child("event");
      firebaseRef.addValueEventListener(new ValueEventListener()
      {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot)
          {
              for (DataSnapshot event : dataSnapshot.getChildren())
              {
                  Log.i("event", event.toString());
              }
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError)
          {
  
          }
      });
  
  
  
  }
  
  private void goLoginScreen()
  {
      Intent intent = new Intent(this, LoginActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | 
      Intent.FLAG_ACTIVITY_CLEAR_TASK | 
              Intent.FLAG_ACTIVITY_NEW_TASK);
      startActivity(intent);
  }
  
  public void logout(View view)
  {
      FirebaseAuth.getInstance().signOut();
      LoginManager.getInstance().logOut();
      goLoginScreen();
  }
  
  
  @Override
  public void onMapReady(GoogleMap googleMap)
  {
      Log.e("fired", "fired");
      LatLng sydney = new LatLng(-34, 15);
      googleMap.addMarker(new MarkerOptions().position(sydney).title("test"));
      googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
  }
  </code></pre>
  
  <p><strong>MapsActivity code:</strong></p>
  
  <pre><code>public class MapsActivity extends FragmentActivity implements 
  OnMapReadyCallback
  {
  
  private GoogleMap mMap;
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_maps);
      // Obtain the SupportMapFragment and get notified when the map is ready 
      to be used.
      SupportMapFragment mapFragment = (SupportMapFragment) 
      getSupportFragmentManager()
              .findFragmentById(R.id.map);
      mapFragment.getMapAsync(this);
  }
  
  
  /**
   * Manipulates the map once available.
   * This callback is triggered when the map is ready to be used.
   * This is where we can add markers or lines, add listeners or move the 
     camera. In this case,
   * we just add a marker near Sydney, Australia.
   * If Google Play services is not installed on the device, the user will be 
     prompted to install
   * it inside the SupportMapFragment. This method will only be triggered once 
     the user has
   * installed Google Play services and returned to the app.
   */
  @Override
  public void onMapReady(GoogleMap googleMap)
  {
      mMap = googleMap;
      Log.e("fired", "fired");
      // Add a marker in Sydney and move the camera
      LatLng sydney = new LatLng(-34, 15);
      mMap.addMarker(new MarkerOptions().position(sydney).title("test"));
      mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
  }
  }
  </code></pre>