5

Am trying to display a map but it displays this error,"The method getSupportFragmentMananger()is undefined for the type main" Please Help. thanks. I am using Google maps ap

package com.maps;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;



import android.app.Activity;

public class main extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        GoogleMap mMap;
        mMap = ((MapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

        //can pass dynamic variables
        final LatLng place = new LatLng(-37.81319, 144.96298);
       Marker melbourne = mMap.addMarker(new MarkerOptions()
                                  .position(place)
                                  .title("Melbourne")
                                  .snippet("Population: 4,137,400")
                                  .icon(BitmapDescriptorFactory.fromResource(android.R.drawable.bottom_bar)));


    }
}
andy
  • 1,947
  • 5
  • 27
  • 46

1 Answers1

17
public class main extends Activity

you should use either AppCompatActivity or FragmentActivity, E.g.

public class mai extends AppCompatActivity

instead of

public class main extends Activity
Blackbelt
  • 156,034
  • 29
  • 297
  • 305
  • 1
    ERROR: Cannot cast from Fragment to MapFragment – Rishabh Srivastava Sep 27 '13 at 10:13
  • What happens is that when you extend Fragment Activity instead of Activity, it means that you will not be able to call your activity from another activity that does not extend Fragment activity and this becomes a challenge. I have tried to do this but what I have been getting is NoClassDefFoundError. In this instance how does one call the activity in another class – olasammy Oct 10 '13 at 16:05