Get permission before downloading the Google Maps Android?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
23 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 | 23 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,187 answers
0 comments
40,796 users