Get current Address

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.