android - onLocationChanged is not being called -
i trying show current location on map onlocationchanged not being called.
@override public void onlocationchanged(location location) { log.d("called", "onlocationchanged"); latlng latlng = new latlng(location.getlatitude(), location.getlongitude()); markeroptions markeroptions = new markeroptions(); markeroptions.position(latlng); markeroptions.title("current position"); markeroptions.icon(bitmapdescriptorfactory.defaultmarker(bitmapdescriptorfactory.hue_magenta)); mmap.addmarker(markeroptions); mmap.movecamera(cameraupdatefactory.newlatlng(latlng)); mmap.animatecamera(cameraupdatefactory.zoomto(11)); }
and here oncreate code
locationmanager lm = (locationmanager) getsystemservice(context.location_service); lm.requestlocationupdates(locationmanager.gps_provider, 1000, 0, this);
have both permissions
requestpermissions({ android.manifest.permission.access_fine_location, android.manifest.permission.access_coarse_location, }, requestperm);
and override onrequestpermissionsresult
handle grant/reject?
@override public void onrequestpermissionsresult(int requestcode, string[] permissions, int[] grantresults) {}
Comments
Post a Comment