GPS Positioning can provide accurate and detailed data. But sometimes we cannot get data through GPS, such as in the room, without GPS functions. Then we need other positioning methods. base station positioning is a good choice. When our mobile phone is turned on, the mobile phone will automatically contact the most signal wireless communication station, registration information, this communication station is what we call the base station, each base station has its own ID, we can find the location of the base station through the ID of this base station, and the density of the base station in domestic cities can reach below 500 or lower, so we can determine our location in general. Preparation tool: 1. telephonymanager: mainly provides a series of get methods for accessing the status and information related to mobile phone communication. The information includes the status and information of the mobile phone SIM, the status of the Telecom Network, and the information of the mobile phone user. Here, we obtain the base station information through this class. 2. gsmcelllocation: loads information obtained from telephonymanager. 3. jsonobject and jsonarray: Form JSON-related classes. 4. Networking-related classes. Code: 1. start button and artboard mtextview = (textview) findviewbyid (R. id. textview); mbutton = (button) findviewbyid (R. id. button); 2. obtain the base station information mtmanager = (telephonymanager) This. getsystemservice (context. telephony_service); gsmcelllocation GCL = (gsmcelllocation) mtmanager. getcelllocation (); int cid = GCL. getcid (); int LAC = GCL. getlac (); int MCC = integer. valueof (mtmanager. getnetworkoperator (). substring (0, 3); int MNC = intege R. valueof (mtmanager. getnetworkoperator (). substring (3, 5); string getnumber = ""; getnumber + = ("CID:" + CID + "\ n"); getnumber + = ("CID: "+ LAC +" \ n "); getnumber + = (" CID: "+ MCC +" \ n "); getnumber + = (" CID: "+ MNC +" \ n "); 3. create JSON try {jsonobject jobject = new jsonobject (); jobject. put ("version", "1.1.0"); jobject. put ("host", "maps.google.com"); jobject. put ("request_address", true); If (MCC = 460) {jobject. put ("Address_language", "zh_cn");} else {jobject. put ("address_language", "en_us");} jsonarray jarray = new jsonarray (); jsonobject jdata = new jsonobject (); jdata. put ("cell_id", CID); jdata. put ("location_area_code", LAC); jdata. put ("mobile_country_code", MCC); jdata. put ("mobile_network_code", MNC); jarray. put (jdata); jobject. put ("cell_towers", jarray); 4. create a connection, send a request, and accept the response defaulthttpclient client = new defaulth Ttpclient (); httppost post = new httppost ("http://www.google.com/loc/json"); stringentity Se = new stringentity (jobject. tostring (); Post. setentity (SE); httpresponse resp = client.exe cute (post); bufferedreader BR = NULL; If (resp. getstatusline (). getstatuscode () = httpstatus. SC _ OK) {BR = new bufferedreader (New inputstreamreader (resp. getentity (). getcontent (); stringbuffer sb = new stringbuffer ();} 5. For more information, see JSON server responsestringbuffer sb = new stringbuffer (); string result = Br. Readline (); While (result! = NULL) {sb. append (getnumber); sb. append (result); Result = BR. readline ();} mtextview. settext (sb. tostring (); capability: <uses-Permission Android: Name = "android. permission. access_fine_location "> </uses-Permission> <uses-Permission Android: Name =" android. permission. internet "> </uses-Permission>