You should use Fragment. It is like that on layout;
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/myMapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true" />
To use that you should add google-play-services_lib project to your project build path.
Then in your class you should implement FragmentActivity like that;
public class Main extends FragmentActivity{
private GoogleMap mMap;
UiSettings settings;
MapController mapController;
GeoPoint geopoint;
RectF oval;
Canvas canvas;
int mRadius = 5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setUpMap();
}
@Override
protected void onResume(){
super.onResume();
setUpMap();
}
private void setUpMap(){
if (mMap != null) {
return;
}
mMap=((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.myMapView)).getMap();
if (mMap == null) {
return;
}
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setCompassEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(true);
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(place1, 15));
mMap.setTrafficEnabled(true);
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
}
You should obtain an apikey for google maps from this link or you can continue step by step from this link
Add your apikey and permissions to Manifest file like that;
<uses-permission android:name="your_package.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your_api_key"/>
Note: meta-data must be inside of application in your manifest.