1

I can't find my current location button in Android Marshmallow. I am using google map api.

I have already enabled these:

 mMap.setMyLocationEnabled(true);
        mMap.getUiSettings().setMyLocationButtonEnabled(true);

cant find this button in my layout

I have tried in jellybean, lollipop and it is working fine but I can't find this button and my current location marker in Marshmallow.
Why is this happening and how can I fix it?

Community
  • 1
  • 1
  • Have you tried to change playservice in the Gradle file to the same as the Device's playservice? (REQUIRED PLAY SERVICE UPDATE) – CJR Jun 16 '16 at 13:56
  • Did you ask for permissions programatically? if you are using the latest build tool and compiling for Marshmallow, you will need to ask for certain permissions at runtime instead of only defining them in the manifest. More info here: https://developer.android.com/training/permissions/requesting.html. – EricDS Jun 16 '16 at 14:36
  • i don't know what's wrong with marshmallow.My App runs perfectly on lollipop and jellybean. my compileSdkVersion is 23 andbuildToolsVersion is "23.0.3". – Bhavin Himmat Goswami Jun 16 '16 at 18:46

1 Answers1

0

Got the solution for my problem:

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

        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(Mumbai.getCenter(), 11));

        if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

            return;
        }