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 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
Post a Comment