0

I have a google maps activity that extends FragmentActivity in my app and work fine (is just the code that add android studio when create a google maps project):

 public class MyMap extends FragmentActivity implements OnMapReadyCallback {
    private GoogleMap mMap;
    private String TAG = "MAIN ACTIVITY";
    protected static String CHECK_PERMISSION = "check.permission";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_beach_map);
        String appVersion = "v1";

        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }


    @TargetApi(23)
    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        addMarker();
        getUserCurrectLocation(mMap);
    }
    .
    .
    .

Mymap xml:

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context="mypackage.com"
android:name="com.google.android.gms.maps.SupportMapFragment" />

In my mainActivity I'm using navigationDrawer and I'm refreshing the main layout with a FrameLayout that is working fine, too.

My problem comes when I try to add my google map class in the frame layout. I'm doing this to set the different fragments in the FrameLayout:

public void setFragment(int position) {
        FragmentManager fragmentManager;
        FragmentTransaction fragmentTransaction;
        switch (position) {
            case 0:
                fragmentManager = getSupportFragmentManager();
                fragmentTransaction = fragmentManager.beginTransaction();
                FirstFragment inboxFragment = new FirstFragment();
                fragmentTransaction.replace(R.id.flContent, inboxFragment);
                fragmentTransaction.commit();
                break;
            case 1:
                fragmentManager = getSupportFragmentManager();
                fragmentTransaction = fragmentManager.beginTransaction();
                MyMap starredFragment = new MyMap();
                fragmentTransaction.replace(R.id.flContent, starredFragment);
                fragmentTransaction.commit();
                break;
        }
    }

But, here I'm getting a wrong 2º argument type. Found: 'mypackage.com', required: 'android.support.v4.app.Fragment':

fragmentTransaction.replace(R.id.flContent, starredFragment);

It's possible to add to the fragmentTransaction a FragmentActivity or is another way to can add my map into the FrameLayout?? I'm searching here but I can't find any question like this....

Simpson
  • 593
  • 5
  • 20

0 Answers0