Tag: Get current address
/** * Gets the current address */private void GetPosition () {locationclient = new locationclient (this);//Set positioning conditions locationclientoption option = new Locationclientoption (); Option.setopengps (true); Whether to open Gpsoption.setcoortype ("Bd09ll"); Sets the coordinate type of the return value. Option.setprodname ("Salebaby"); Set the product line name. It is recommended that you use a custom product line name to provide more efficient and accurate positioning. Option.setscanspan (Update_time); Sets the time interval for timed positioning. Unit milliseconds locationclient.setlocoption (option);//Register Location Listener Locationclient.registerlocationlistener (new Bdlocationlistener () {@Overridepublic void onreceivelocation (bdlocation location) {//TODO auto-generated method stubif (location = = null) { return;} Locate information related data stringbuffer SB = new StringBuffer ("Time:"), Sb.append (Location.gettime ()), Sb.append ("\ Nerror code: "); Sb.append (Location.getloctype ()); Sb.append (" \nlatitude: "); Sb.append (Location.getlatitude ()); Sb.append ("\nlontitude:"); Sb.append (Location.getlongitude ()); Sb.append ("\nradius:"); Sb.append ( Location.getradius ()); if (location.getloctype () = = bdlocation.typegpslocation) {Sb.append ("\nspeed:"); Sb.append (Location.getspeed ()); Sb.append ("\nsatellite:"); Sb.append (Location.getsatellitenumber ( ));} else if (location.getloctype () = = bdlocation.typenetworklocation) {sb.append ("\naddress:"); Sb.append ( Location.getaddrstr ());} Location_coutns++;sb.append ("\ n Check location update number:"); Sb.append (String.valueof (location_coutns)); Locationtools.getlocationmanager (context); String position = new Locationtools (). getaddress (context); Tv_nowloc.settext (position);});}
Get current Address