使用 Google 日历的 Android 应用程序 - 同步问题 [英] Android app using Google calendar - Sync issue

查看:23
本文介绍了使用 Google 日历的 Android 应用程序 - 同步问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个与 Google 日历交互的 Android 应用.
我已使用 这里.此代码的部分内容在这里.

I am trying to create an android app that interfaces with the Google Calendar.
I have followed the tutorial using content providers from here. Parts of this code are explained here.

我面临以下问题.

  1. 我通过笔记本电脑在线创建了一个新日历TestCalendar,并将其标记为已选择.当我从应用程序查询我的日历时,我可以看到这个新日历,但它显示为未选中 (selected=0).关于为什么会发生这种情况的任何建议?

  1. I created a new calendar TestCalendar from my online from my laptop, and marked it as Selected. When I query for my calendars from the app, I can see this new calendar, but it is shown as unselected (selected=0). Any suggestions on why this could be happening ?

从我的应用程序中,我将一个事件添加到日历中
getContentResolver().insert(eventsUri, event);
该事件反映在手机日历中,但不反映在在线版本中.要在线推送这个新活动,我必须手动同步日历,或者打开自动同步,我认为这不是正确的做法.任何可以帮助的建议/链接?

From my app, I add an event to the calendar by
getContentResolver().insert(eventsUri, event);
The event is reflected in the calendar on phone, but it is not reflected in the online version. To push this new event online, I have to manually Synchronize the calendar, or turn the Auto Sync on, which I believe is not the right way in which this should be done. Any suggestions/links which could help ?

推荐答案

1) 你能转储你的日历并发布结果吗?

1) Can you dump your calendar and post the result?

注意:
安卓Android > API Lvl 14 你必须设置可见 = 1(选择不再可用)

Notice:
Android < API Lvl 14 you must set selected = 1
Android > API Lvl 14 you must set visible = 1 (selected is not longer available)

转储:

cursor = contentResolver.query(Uri.parse(CALENDAR_URI),null, null, null,null);

while (cursor.moveToNext()) {
   for (int i = 0; i < cursor.getColumnCount(); i++) {
    Log.e("XXX", cursor.getColumnName(i) + ": " + cursor.getString(i));
    }
}

CALENDAR_URI = content://com.android.calendar/calendars(从 Froyo 开始)或 content://calendar/(在 Froyo 之前)

CALENDAR_URI = content://com.android.calendar/calendars (since Froyo) or content://calendar/ (before Froyo)

2) https://stackoverflow.com/a/11652415/411951

这篇关于使用 Google 日历的 Android 应用程序 - 同步问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆