【问题标题】:Can't do setId() when insert calendar (calendar api for java)插入日历时无法执行 setId()(java 的日历 api)
【发布时间】:2018-10-30 04:04:09
【问题描述】:

插入日历时我不能setId() (Calendar api for java)。

我收到一个错误:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 错误请求{“代码”:400,“错误”:[ { “域”:“全球”, "message": "无效的资源 id 值。", “原因”:“无效” } ], "message": "无效的资源 id 值。" }

我的代码:

private fun insertCalendar(){
    object : Thread() {
        override fun run() {
            val calendar = com.google.api.services.calendar.model.Calendar()
                    .setSummary("Lich hoc ictu")
                    .setDescription("Lich hoc ictu")
                    .setTimeZone("Asia/Ho_Chi_Minh")
                    .setId("calendarictu@group.calendar.google.com")
            service.Calendars().insert(calendar).execute()
            runOnUiThread {
                Toast.makeText(this@MainActivity, "Added", Toast.LENGTH_LONG).show()
            }
        }
    }.start()

}

【问题讨论】:

    标签: android kotlin google-api


    【解决方案1】:

    我认为您的问题的答案在这里: https://stackoverflow.com/a/23799150/8713068

    所以基本上你不能设置自己的 ID,谷歌会为你做。

    你有一些关于检索日历 ID 的信息: https://developers.google.com/calendar/v3/reference/calendars

    【讨论】:

    • 嗯!其他,我需要一个日历ID,有什么办法吗?
    • 在第二个链接中有注释:id - string - Identifier of the calendar. To retrieve IDs call the calendarList.list() method. 但我不确定这是否是正确的方法
    • 谢谢!我使用了calendarList.list(),它不需要设置自定义日历id
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2017-02-19
    • 2012-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多