Private string mresult = NULL; private string mprovincename; // province private string mchcityname; // city private int get_city_success = 1; private int get_city_failure = 2; // handler receives the message for processing and obtains the required information privatehandler mhandler = new handler () {public void handlemessage (Android. OS. message MSG) {super. handlemessage (MSG); If (MSG. what = get_city_success) {// SRC. split ("\ t") returns a string array separated by a tab (Tab key) string [] resul TS = mresult. split ("\ t"); If (results. length >=5) {mprovincename = Results [4]; mchcityname = Results [5];} log. I ("---- Province:" + mprovincename, "---- City:" + mchcityname);} else if (MSG. what = get_city_failure) {// failed to get };}; // access Sina interface to obtain IP address and geographical location information // return data format: 1 121.15.0.0121.15.215.255 China Guangdong Shenzhen Telecom private void getcurrentprovinceandcity () {final string url = "http://int.dpool.sina.com.cn/iplookup/iplookup.php? "; Httpget = new httpget (URL); try {httpresponse = new defaulthttpclient(cmd.exe cute (httpget); statusline = httpresponse. getstatusline (); If (statusline! = NULL & statusline. getstatuscode () = 200) {mresult = entityutils. tostring (httpresponse. getentity ()). trim (); mhandler. sendemptymessage (get_city_success) ;}} catch (exception e) {log. D (TAG, "getcurrentprovinceandcity, exception"); E. printstacktrace (); mhandler. sendemptymessage (get_city_failure );}}