开发者

Obtaining Coordinates from "Share this place" in Google Maps

开发者 https://www.devze.com 2023-04-08 02:53 出处:网络
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 appli

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 pla开发者_JAVA技巧ce" action?


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

How can I find the latitude and longitude from address?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号