简体   繁体   中英

Google Calendar API: add latitude longitude to Calendar Event programmatically in android?

I retrieve the lat & long for the event detail. And I want to send lat long to calendar using intent. I search it on google but didn't find any solution? Please help.

You could attain this using CalendarContract class. Adding location is possible using this class; CalendarContract.Events.EVENT_LOCATION

More info here Adding event with reminders to calendar with 'Intent.putExtra()' way of doing

Using the Google API with other languages, I have been able to pass the Latitude and Longitude as a string and the map link in the Calendar Event drops a pin in the correct position. I would imagine that that API has the same behavior for all languages.

Source: Latitude and Longitude of the White House

C# psuedo code

var latitude = "38.8976763";
var longitude = "-77.0365298";

new Event
{
   // beginning parameters
   ...

   // The comma is optional and replaceable with a single space
   Location = $"{latitude}, {longitude}", 

   ... 
   // final parameters
}

image from Event detail added by Google API: 使用Google API添加事件的屏幕截图

Resulting Link when clicking map from the Calendar Event:

map

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM