Google Maps Current Location Button Does Not Appear

Asked 2 years ago, Updated 2 years ago, 43 views

Nice to meet you.I recently started developing apps and am trying to create apps using Google Maps.

I created a project from New project→Google Maps Activity based on the sample, got the API key, and implemented the current location button, congestion situation, etc.

However, when I updated to Android 6.0, all the features I implemented stopped working.

If you don't mind, please let me know.

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

        // Add a marker in Sydney and move the camera
        LatLng sydney = new LatLng (-34,151);
        mMap.addMarker(newMarkerOptions().position(sydney).title("Marker in Sydney"));
        mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)));

        if(ActivityCompat.checkSelfPermission(this,android.Manifest.permission.ACCESS_FINE_LOCATION)!=PackageManager.PERMISSION_GRANTED&&ActivityCompat.checkSelfPermission(this,android.Manifest.permission.ACCESSION)!=PackageManager.Permission.Permission.PERMATION! PLACCESSION
            // TODO:consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[]permissions,
            //                                          int[]grantResults)
            // to handle the case where the user grants the permission.See the documentation
            // for ActivityCompat# requestPermissions for more details.
            return;
        }
        mMap.setMyLocationEnabled(true);

    }
}

android google-maps

2022-09-29 22:13

1 Answers

API level 23 requires Run Time Permissions.
Read the English text where you are commenting out.

This post was posted as a community wiki based on @quesera2's comments.


2022-09-29 22:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.