0

私の LG-G3 には、「電話」という名前のデフォルトのカレンダーがあります。Google のものではありません。

イベントをユーザーの Google カレンダーと同期するアプリケーションを作成しましたが、クエリですべてのカレンダーを選択すると、「電話」カレンダーも取得されます。グーグルカレンダーではないので、グーグルカレンダーの機能(挿入、削除など)が使えません。

その名前を除いて、「電話」カレンダーとGoogle canledarsの間に違いは見られません。カレンダーが Google のものかどうかを知る方法はありますか?

これは私のクエリです:

        String[] l_projection = new String[] { Calendars._ID, Calendars.CALENDAR_DISPLAY_NAME, Calendars.CALENDAR_ACCESS_LEVEL, Calendars.ALLOWED_REMINDERS, Calendars.SYNC_EVENTS };
        Uri l_calendars;
        if (Build.VERSION.SDK_INT >= 8) {
            l_calendars = Uri.parse("content://com.android.calendar/calendars");
        } else {
            l_calendars = Uri.parse("content://calendar/calendars");
        }

        try {
            Cursor l_managedCursor = activity.getContentResolver().query(l_calendars, l_projection, null, null, null); 
            if (l_managedCursor.moveToFirst()) {
                String l_methodAllow;
                String l_accessPermission;
                String l_calName;
                String l_calId;
                String l_syncEvents;
                int l_cnt = 0;
                int l_syncEventsCol = l_managedCursor.getColumnIndex(l_projection[4]);
                int l_methodAllowCol = l_managedCursor.getColumnIndex(l_projection[3]);
                int l_accessPermissionCol = l_managedCursor.getColumnIndex(l_projection[2]);
                int l_nameCol = l_managedCursor.getColumnIndex(l_projection[1]);
                int l_idCol = l_managedCursor.getColumnIndex(l_projection[0]);
                do {
                    String access = l_managedCursor.getString(l_accessPermissionCol);
                    if (access.equals("500") || access.equals("600") || access.equals("700") || access.equals("800")) {
                        l_syncEvents = l_managedCursor.getString(l_syncEventsCol);
                        l_methodAllow = l_managedCursor.getString(l_methodAllowCol);
                        l_accessPermission = l_managedCursor.getString(l_accessPermissionCol);
                        l_calName = l_managedCursor.getString(l_nameCol);
                        l_calId = l_managedCursor.getString(l_idCol);

                        calNames.add(l_calName);
                        // ....

                        ++l_cnt;
                    }
                } while (l_managedCursor.moveToNext());
            }
        } catch (Exception e) {
            // ...
        }
4

1 に答える 1

1

Google カレンダーは、カレンダー ID のドメイン名を見ることで識別できます。プライマリ カレンダーの場合、カレンダー ID ドメイン名は @gmail.com です。サブ カレンダーの場合、カレンダー ID ドメイン名は group.calendar.google.com です。

于 2015-03-16T15:38:42.190 に答える