The minimum amount of code I can think of to open a map looks like:
activity_maps.xml:
<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" />
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
Intent intent = new Intent(this, MapsActivity.class);
intent.putExtra("LATITUDE", 38.65452);
intent.putExtra("LONGITUDE", -90.18471);
startActivity(intent);
}
}
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
{
private double dLatitude = 0.0;
private double dLongitude = 0.0;
private GoogleMap mMap;
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
Bundle bundle = getIntent().getExtras();
dLatitude = bundle.getDouble("LATITUDE");
dLongitude = bundle.getDouble("LONGITUDE");
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady( GoogleMap googleMap )
{
mMap = googleMap;
LatLng latlng = new LatLng(dLatitude, dLongitude);
mMap.addMarker(new MarkerOptions().position(latlng).title("Marker"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(latlng));
}
}
You can add to it from here.