How to retrieve the GPS location via SMS

2020-02-29 01:46发布

问题:

I made an Application that gives me the location of my Android phone.

Now I want to make a method that helps me to retrieve the GPS location of my phone (latitude longitude or the address if possible) with an SMS.

Exemple: phone number 558899. I send an Sms with "get location" to 558899 an get a message back with the coordinates.

回答1:

this may help:

"Capture" incoming SMS: http://www.codemobiles.com/forum/viewtopic.php?p=95

Send SMS: http://www.anddev.org/how_to_send_sms-t552.html

Edit: Dead link. I don't remember what exactly was in it, just like Google's cache and Internet Wayback Machine. Following link should have some info on topic:

http://lamiaamb.wordpress.com/2012/03/19/android-capture-an-incoming-sms/



回答2:

Use the Geocoder class. Pass it's getFromLocation() method the longitude and latitude and the maximal number of results you want to get returned. You'll get a List of Address objects.