Rage
Rage

Reputation: 191

Override mylocation button in android Google maps api v2

I am trying yo override Google map's default my location button to display "GPS is not enabled" message if the user is pressing the mylocation button when gps is not enabled. How can i do this?

Upvotes: 2

Views: 4480

Answers (2)

Sattar
Sattar

Reputation: 2633

i can add the code based on Hoan Answer

 map.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() {
        @Override
        public boolean onMyLocationButtonClick() {
            Toast.makeText(getActivity(), "Good", Toast.LENGTH_SHORT).show();
            return false;
        }
    });

you can make what you want in the function

Upvotes: 0

Hoan Nguyen
Hoan Nguyen

Reputation: 18151

register for the mylocation click using setOnMyLocationButtonClickListener and in onMyLocationButtonClick () show your message.

Upvotes: 6

Related Questions