locationmanager - how to set radius within current location android apps -


i want set radius of office. have current location code. want set radius when in radius, can use application. right current location longitude , latitude

public gpstracker(context context) {     this.context = context;     getlocation(); }  public location getlocation() {     try {         locationmanager = (locationmanager) context.getsystemservice(location_service);          isgpsenabled = locationmanager.isproviderenabled(locationmanager.gps_provider);          isnetworkenabled = locationmanager.isproviderenabled(locationmanager.network_provider);          if(!isgpsenabled && !isnetworkenabled) {          } else {             this.cangetlocation = true;              if (isnetworkenabled) {                  locationmanager.requestlocationupdates(                         locationmanager.network_provider,                         min_time_bw_updates,                         min_distance_change_for_updates, this);                  if (locationmanager != null) {                     location = locationmanager                             .getlastknownlocation(locationmanager.network_provider);                      if (location != null) {                          latitude = location.getlatitude();                         longitude = location.getlongitude();                     }                 }              }              if(isgpsenabled) {                 if(location == null) {                     locationmanager.requestlocationupdates(                             locationmanager.gps_provider,                             min_time_bw_updates,                             min_distance_change_for_updates, this);                      if(locationmanager != null) {                         location = locationmanager.getlastknownlocation(locationmanager.gps_provider);                          if(location != null) {                             latitude = location.getlatitude();                             longitude = location.getlongitude();                         }                     }                 }             }         }      } catch (exception e) {         e.printstacktrace();     }      return location; }   public void stopusinggps() {     if(locationmanager != null) {         locationmanager.removeupdates(gpstracker.this);     } }  public double getlatitude() {     if(location != null) {         latitude = location.getlatitude();     }     return latitude; }  public double getlongitude() {     if(location != null) {         longitude = location.getlongitude();     }      return longitude; }  public boolean cangetlocation() {     return this.cangetlocation; }  public void showsettingsalert() {     alertdialog.builder alertdialog = new alertdialog.builder(context);      alertdialog.settitle("gps settings");      alertdialog.setmessage("gps not enabled. want go settings menu?");      alertdialog.setpositivebutton("settings", new dialoginterface.onclicklistener() {          @override         public void onclick(dialoginterface dialog, int which) {             intent intent = new intent(settings.action_location_source_settings);             context.startactivity(intent);         }     });      alertdialog.setnegativebutton("cancel", new dialoginterface.onclicklistener() {          @override         public void onclick(dialoginterface dialog, int which) {             dialog.cancel();         }     });      alertdialog.show(); } 


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -