dependencies { implementation 'com.google.android.gms:play-services-basement:18.0.0' } @Override public void onCreate() { super.onCreate(); GoogleApiAvailability.getInstance().makeGooglePlayServicesAvailable(this); } FusedLocationProviderClient fusedLocationClient = LocationServices.getFusedLocationProviderClient(this); fusedLocationClient.getLastLocation().addOnSuccessListener(location -> { if (location != null) { double latitude = location.getLatitude(); double longitude = location.getLongitude(); } }); GoogleMapOptions options = new GoogleMapOptions(); SupportMapFragment fragment = SupportMapFragment.newInstance(options); getSupportFragmentManager().beginTransaction() .add(R.id.map_container, fragment) .commit(); fragment.getMapAsync(googleMap -> { if (googleMap == null) { } else { } });


上一篇:
下一篇:
切换中文