gpt4 book ai didi

android - 有没有办法在不使用 gdata-java-client 的情况下访问日历条目?

转载 作者:太空宇宙 更新时间:2023-11-03 11:27:31 25 4
gpt4 key购买 nike

是否可以从手机离线获取日历条目?似乎唯一的方法是使用 gdata-java-client .

最佳答案

Josef 和 Isaac 访问日历的解决方案仅适用于 Android 2.1 及更早版本。 Google 已将 2.2 中的基本内容 URI 从“content://calendar”更改为“content://com.android.calendar”。此更改意味着最好的方法是尝试使用旧的基本 URI 获取游标,如果返回的游标为空,则尝试使用新的基本 URI。

请注意,我从 open source test code 中获得了这种方法Shane Conder 和 Lauren Darcey 提供了他们的 Working With The Android Calendar文章。

private final static String BASE_CALENDAR_URI_PRE_2_2 = "content://calendar";
private final static String BASE_CALENDAR_URI_2_2 = "content://com.android.calendar";
/*
* Determines if we need to use a pre 2.2 calendar Uri, or a 2.2 calendar Uri, and returns the base Uri
*/
private String getCalendarUriBase() {
Uri calendars = Uri.parse(BASE_CALENDAR_URI_PRE_2_2 + "/calendars");
try {
Cursor managedCursor = managedQuery(calendars, null, null, null, null);
if (managedCursor != null) {
return BASE_CALENDAR_URI_PRE_2_2;
}
else {
calendars = Uri.parse(BASE_CALENDAR_URI_2_2 + "/calendars");
managedCursor = managedQuery(calendars, null, null, null, null);

if (managedCursor != null) {
return BASE_CALENDAR_URI_2_2;
}
}
} catch (Exception e) { /* eat any exceptions */ }

return null; // No working calendar URI found
}

关于android - 有没有办法在不使用 gdata-java-client 的情况下访问日历条目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/846942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com