▲ 1 r/WearOS
Unable to read calendar info on watch
This is a dev question: does anyone know if WearOS makes calendar information available via content provider?
I'm writing a simple agenda application that fetches upcoming calendar events for all my calendars, but all my queries are returning empty data.
- The Google Calendar app is installed on my watch and shows my upcoming events.
- The Google Calendar complication works fine.
- I ran my code both on an emulator logged in to my account, as well as on my physical watch (Pixel Watch 4).
My test code runs fine on my Android phone, so I'm suspecting it's a limitation of Google Calendar on the watch, for example listing all calendars:
val calendars = mutableListOf<CalendarItem>()
val projection = arrayOf(
CalendarContract.Calendars._ID,
CalendarContract.Calendars.CALENDAR_DISPLAY_NAME,
CalendarContract.Calendars.CALENDAR_COLOR
)
val cursor = context.contentResolver.query(
CalendarContract.Calendars.CONTENT_URI, projection,
null, null, null
)
cursor?.use {
while (it.moveToNext()) {
val id = it.getLong(0)
val displayName = it.getString(1)
val color = it.getInt(2)
calendars.add(CalendarItem(id, displayName, color))
}
}
All documentation I found seems to suggest this should work on WearOS but I tried looking for other similar apps and they either aren't available anymore, or seem to depend on a mobile app. I'm starting to think that this is deprecated functionality.
Are my only options here to make a companion app, or to implement the Google Calendar API?
u/DrFossil — 2 days ago