5

When viewing the details of any location in Google Maps, there's an option for "Share this place". I have successfully added myself to the list of receivers by adding this intent-filter to my application in the manifest:

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>

The extras passed along with this bundle are Intent.EXTRA_SUBJECT and Intent.EXTRA_TEXT. I retrieved these extras in my activity using:

Bundle extras = getIntent().getExtras();

Intent.EXTRA_SUBJECT contains a string with the title of the location. Intent.EXTRA_TEXT contains a string with a detailed address of the location and a mobile maps URL.

Is it at all possible to retrieve the GPS co-ordinates (latitude and longitude) of the location from the "Share this place" action?

mattprecious
  • 302
  • 3
  • 15

1 Answers1

2

You can use geocoder to obtain the location from the address:

How can I find the latitude and longitude from address?

Community
  • 1
  • 1
artkoenig
  • 7,117
  • 2
  • 40
  • 61
  • 1
    I was hoping for a more direct approach without having to look up the address, but this does the trick. Thanks! Note: I had to strip the URL from the text in order for the Geocoder to locate the address correctly. – mattprecious Oct 30 '11 at 06:54