Get permission before downloading the Google Maps Android?

0 like 0 dislike
12 views
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
by | 12 views

1 Answer

0 like 0 dislike
RTFM
Permission check in onCreate(), if not, inquire with requestPermissions(), then checking the query result in onRequestPermissionsResult().
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
4 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,700 users