Hello, you must obtain permission
before downloading the Google Maps Android. Now it turns out that after agreeing on the definition of my location, MyLocation button does not appear, but after restarting the application the button is already in place. The logic is clear that you must build the solution before loading the map. However, all the physical movement of parts of the code in all possible places to no avail.
The code itself:
protected void onCreate(Bundle savedInstanceState) { ActivityCompat.requestPermissions( this new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_LOCATION_REQUEST_CODE ); super.onCreate(savedInstanceState); setContentView(R. layout.activity_maps); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R. id.map); mapFragment.getMapAsync(this); } @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mMap.setMyLocationEnabled(true); } if (MY_LOCATION_REQUEST_CODE == 1) { } else { } mMap.getUiSettings().setMyLocationButtonEnabled(true);
Tell me, how to build a permission before downloading the maps?
Thanks in advance