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?
You can use geocoder to obtain the location from the address:
How can I find the latitude and longitude from address?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With