Android google map on click of current location button show alert box if gps not enabled -


i have implemented google map in app. when click on current location button wanted show alert box if gps not enabled.

i tried way got view of button.

    supportmapfragment fm = (supportmapfragment) getsupportfragmentmanager()                 .findfragmentbyid(r.id.map);           view plusminusbutton = fm.getview().findviewbyid(1);         view locationbutton = fm.getview().findviewbyid(2); 

using locationbutton tried use setonclicklistener did not help.

my requirement simple when click on image enter image description here if gps not enabled have show alert box saying gps not enabled.

this request , google added feature (in august 2013 think). can listen clicks on location button this:

final context context = this; mmap.setonmylocationbuttonclicklistener(new googlemap.onmylocationbuttonclicklistener() {     @override     public boolean onmylocationbuttonclick() {         locationmanager mgr = (locationmanager) getsystemservice(context.location_service);         if (!mgr.isproviderenabled(locationmanager.gps_provider)) {             toast.maketext(context, "gps disabled!", toast.length_short).show();         }         return false;     } }); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -